MOO-cows Mailing List Archive
[Prev][Next][Index][Thread]
Scattering assignment
-
Date: Mon, 18 Nov 1996 08:23:58 PST
-
From: Chris Schlesiger <cschles@lamp0.arl.army.mil>
-
Content-Type: TEXT/PLAIN; charset=US-ASCII
I've gotten to really like the scattering assignment in the new server
version. I was wondering what people would think of adding on to it the
following:
Type requirements.
So in addition to {target, ...} = expr where target now is one of:
variable
?variable
?variable = default-expr
@variable
One could also use other (optional) special characters besides the ?
and @ which would signify that the element of the expression corresponding
to target must correspond to the specified data type. If not, then raise
E_TYPE. This could eliminate a lot of data checking that a large
percentage of verbs need to do.
So for each of the types: STR, INT, FLOAT, OBJ, ERR, LIST, we would need
a special character prefix. Now, I haven't given much thought to what
characters to use for each (though # immediately comes to mind for OBJ),
and I suppose that whatever characters are chosen would have to be noted
carefully so that people don't accidently start variables with them (and
unintentionally force their data type if used in a scatter assignment),
but I think that's only a minor problem.
So, for example (using # as the prefix for type OBJ):
{x, #y, ?z=0} = {54.7, #2} => x=54.7, y=#2, z=0
{x, #y, ?z=0} = {54.7, 0, "foo"} => E_TYPE
{x, y, ?z=0} = {54.7, 0, "foo"} => x=54.7, y=0, z="foo"
Now, the above suggests that it might be nice to combine the ? with the
type specifier so that z must to be either STR or NUM but not
both, but I think that's probably getting a bit complex.
Comments?
CDRS
Follow-Ups:
Home |
Subject Index |
Thread Index