Logically, it makes the most sense that when a variable goes out of
scope, all its references should become invalid and therefore the above
dereference fails.


If you mean 'runtime error' instead of 'fails',

Actually, I really meant "throws an exception", but thats a discussion for another day. ;)


There's another possibility I thought of after sending my last message,
and that is to have the compiler detect when a local variable has a reference operation applied it to it while its in scope, and allocate it on the heap in that case. It could then be thrown away by the GC when its last reference disappears. This allows you to return a reference to a variable from a function, and not worry about its safety, and also eliminates the performance penalty of checking every dereference.


Also, doesn't this limit the usefulness of references to
pretty much nothing more than another way to circumvent Icon's
call by value semantics?  Is there any other role they can
play?

Circumventing call by value is one use, but there are others. Being able to save and reuse lvalues from functions and generators would help work around the brilliant, but ugly hacks people have come up with. You can also imagine creating data structures of references.


> Sorry, I didn't mean to imply that Icon was a functional language,
but rather that there is an entire class of languages that get
by quite nicely without a reference type.  Use Java as a more
'Icon'-like example.

Well, I program 90% in Java, and I certainly would make use of references there. I cringe every time I have to create a special class or array just because I want to return more than one value from a function. Other examples that motivate having references in Icon don't apply to Java, because Java isn't as rich in other ways.


Louis



-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to