[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
newlispfanclub.alh.net • View topic - Howto Solve Context Collision

Howto Solve Context Collision

Pondering the philosophy behind the language

Howto Solve Context Collision

Postby lotabout » Wed Mar 20, 2013 4:45 am

lotabout
 
Posts: 8
Joined: Sat Mar 09, 2013 9:13 am

Re: Howto Solve Context Collision

Postby Lutz » Wed Mar 20, 2013 5:36 am

Use only one context per module file. Different programmers maintain different contexts. The MAIN context is the only place where other contexts should be loaded and controls the main organization of the program and is maintained by a lead programmer. No context should redefine functions during runtime in contexts not maintained by the same developer.
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: Howto Solve Context Collision

Postby lotabout » Wed Mar 20, 2013 6:23 am

lotabout
 
Posts: 8
Joined: Sat Mar 09, 2013 9:13 am

Re: Howto Solve Context Collision

Postby Lutz » Wed Mar 20, 2013 3:37 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: Howto Solve Context Collision

Postby bairui » Thu Mar 21, 2013 4:46 am

bairui
 
Posts: 64
Joined: Sun May 06, 2012 2:04 am
Location: China

Re: Howto Solve Context Collision

Postby lotabout » Thu Mar 21, 2013 7:02 am

Thank you very much Lutz.

Now I have more confidence in using dynamic scope.

And understand that we can avoid variable capture by putting macros(fexprs) into a seperate context, and use it inside another context. Without interactions, no variable caputure will ever happen to macros(fexprs).

Just for discussion, consider the follwing situation:

Now we have this convension when writting modules(all I can think up):
1. segregate macros. => put them into a seperate context.
2. wrap all codes with a context. => i.e. the name of the module.
3. use only one context(which is specified by No.2) except those used as data
containers(such as dict/hash table)

And what if two developers use the same contex name for different
purpose?
Here, we use contexts as data(dict/hash table, etc.) inside
another global context(to specify module name). Suppose developer A use the
context 'dict' to store (word
explanations) pairs, and developer B happen to use the same context for holding
(word frequency) pairs. Now we have to use both modules, because these two
modules will affect the other by operate on the same context 'dict', both will
fail to some extent.

How to deal with this one?

I have little experience of joinning large projects, but I do believe with the
modules for newLisp increasing, there will be a name collision. Of course we
can have all contexts as data named with a prefix such as "A-dict" or something
like that, which I believe is easy and will work, besides, can we prevent this
from happenning instead of fixed it as a bug?
lotabout
 
Posts: 8
Joined: Sat Mar 09, 2013 9:13 am

Re: Howto Solve Context Collision

Postby cormullion » Thu Mar 21, 2013 11:53 am

cormullion
 
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W

Re: Howto Solve Context Collision

Postby Lutz » Thu Mar 21, 2013 2:25 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: Howto Solve Context Collision

Postby lotabout » Fri Mar 22, 2013 2:10 pm

This trick works!

And I think we should always use this trick when using a context as a data
container inside a module.

Thanks again for being so patient. And surely I will stay with newlisp, it is
just amazing.
lotabout
 
Posts: 8
Joined: Sat Mar 09, 2013 9:13 am

Re: Howto Solve Context Collision

Postby rickyboy » Sat Mar 23, 2013 1:19 am

(λx. x x) (λx. x x)
rickyboy
 
Posts: 595
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: Howto Solve Context Collision

Postby bairui » Sat Mar 23, 2013 6:08 am

Thanks, rickyboy! That helped a lot. I installed racket to see the difference.

Hmm... This is premature of me to say so, but... I like the way newlisp does this better than racket. Which is to say... to my mind, that your are letting x have another value before (g) is called, then it better show up in (g) with that value - not the lexically scoped value, 42.

I think I know why this is strange to me now. I am used to lexically scoped languages where any modification to x would be a permanent change, so referencing x back at the main scope after the (f 2) call would yield the now-modified value, 13 (in the languages I use). So, the (let ((x 13)) ...) code temporarily shadows (you say binds) the global (you say free (the free term may not be limited to globals... right?)) variable x with the value 13. When that (let) expression ends, the binding ends and therefore x goes back to being the value it was prior to this dynamic scope change, 42.

Ok. Apart from some obvious quirks in my terminology, let's say I get that now. Thank you! So, now I'd like to understand what Lutz meant when he said there were good uses for dynamic scope that us lexical scopers are deprived of. Could you elaborate on: "switching and separation of concerns"?

:-D
bairui
 
Posts: 64
Joined: Sun May 06, 2012 2:04 am
Location: China

Re: Howto Solve Context Collision

Postby Lutz » Sat Mar 23, 2013 2:39 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: Howto Solve Context Collision

Postby bairui » Sun Mar 24, 2013 2:53 am

Excellent, Lutz.

Those WP articles and the PDF helped a lot. Thanks! :-)

Your example of handling separate concerns with contexts was clear. That reminds me of one of the GOF patterns... strategy? (I never got into the habit of quoting GOF patterns.)

However, your example shows... completely separate concerns rather than cross-cutting concerns. I googled for AOP in newlisp rather unsuccessfully. It seems that dragonfly has a (wrap_func) that provides an aspect of it (no pun intended).

I will have to play with this to truly understand it. But now I have the means to begin that journey. Thanks, Lutz & rickyboy. Much appreciated. :-D
bairui
 
Posts: 64
Joined: Sun May 06, 2012 2:04 am
Location: China


Return to Whither newLISP?

Who is online

Users browsing this forum: No registered users and 1 guest