Have all undefined variables default to a value specified by &undef. By default, &undef = &null, so existing code works as expected. However, &undef can be reassigned by the programmer. In addition, the semantics of &null are left alone.
Introduce a new constant &bottom (the term is taken from ordered set theory) which compares "below" every value of every other type, so that
&undef := &bottom every (!x>:=0) +:= 1
would increment every positive value by 1, and also set undefined values to 1
For completeless, a &top constant could be introduced as well (someone else suggested &omega)
Yet another behavior could be achieved by introducing another form of &null, say for example, &nil, where &nil automatically converts to 0, or "", or [], or whatever the empty value is for the type expected by the given operator. Then, default behavior for undefined variables would work like in other languages such as Perl,
&undef := &nil
every !x :+= 1 increments every value by 1, whether it is previously defined or not.
I'm sure someone could think of uses for other values &undef in some circumstances.
Louis
David Gamey wrote:
Steve Wampler wrote:
On Wed, 2003-10-08 at 04:29, Majorinc, Kazimir wrote:I believe what is being suggested is a return to (and extension of) the old SNOBOL4 semantics. Null coercion caused a lot of programming problems. In particular, a slight typo in a variable name was often very hard to find. I'm not outright against the suggestion, but I think that it needs to be carefully examined. There may need to be some buy back with some other feature. For example, requiring all varaibles to be declared would counter that problem. However, I'm not sure I like the price. I also think that the ability to initialize in a declaration, as has already been suggested, might provide a workable alternative with a smaller price. Fnally, some of the coercions may also be challenging where several types are possible and with some of the object oriented features being proposed.
Another attractive possibility is to make &null behave as the weakest or neutral element in every expression (as it is at least partly suggested by name), so many frequently used idioms shouldn't need initialization: x:+=1 as the most obvious one, but also m<:=!L, recently discussed put(x,1) and perhaps many others.
You're saying that comparisons with &null should always succeed (as in the m <:= !L case), or that the behavior in x +:= 1 is to have &null coerced to 0 and in put(x,1) coerced to an empty list? I'm not sure of the definition of "behave" in the above...
David
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Unicon-group mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/unicon-group
------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. SourceForge.net hosts over 70,000 Open Source Projects. See the people who have HELPED US provide better services: Click here: http://sourceforge.net/supporters.php _______________________________________________ Unicon-group mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/unicon-group
