[This mail was originally sent from my work account, but it
appears to be hung up there for some reason...]
This isn't particularly critical, but I thought people
might want to think about this before Unicon's syntax
becomes locked-in (hmmm, maybe it's too late already...)
Currently Unicon supports the following syntax for
method/procedure/initially parameters:
var[:type][:defaultvalue]
as it stands, this has a few idiosyncracies:
(a) Because you cannot distinguish the name of a type
from a program variable, things like:
procedure foo(a:table)
record A(x,y,z)
procedure foo(a:A)
don't work as you might expect.
(b) You are constrained (enforced by the the translator)
from using anything other than a literal as the
default value, so:
procedure foo(a:set())
procedure foo(a:A(1,2,3))
procedure foo(one, two:one)
are not possible, though they are perfectly 'reasonable'
from an initialization point of view (he claims).
Because of the ambiguity of x:y syntactically, both of these
(and related) issues are actually pretty hard to 'fix'.
However, if the syntax instead were (say):
var[:type][=defaultvalue]
then both could be handled, since the test for checking
type in (for example):
procedure proc(x:integer, i:integer=1)
could be implemented as if the code were (I'd actually
expect the 2nd check to be slightly different, but this
is simpler to illustrate):
procedure proc(x, i)
x := __checkType(x,"integer") | runerr(101, x)
(/i := 1) | (i := __checkType(i,"integer") | runerr(101,i)
here, *any* type (record type, class name, structure) becomes
'checkable' and *any* expression can be used to compute
the default value:
procedure foo(a:set=set())
procedure foo(a=&pi)
procedure foo(a:real=2*sin(1.0))
procedure foo(a:file=open(DEF_FILE,"r"))
procedure foo(a=create f())
etc.
Comments? Not worth it? Too late? Generally a bad idea?
Better syntax, for example, perhaps:
procedure foo(a(real):=2*sin(1.0)) ?
-Steve
--
Steve Wampler [EMAIL PROTECTED]
The gods that smiled upon your birth are laughing now. -- fortune cookie
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group