[DGD]varargs void foo(object bar)
Frank Schmidt
franks at colargol.tihlde.hist.no
Mon Nov 30 10:41:41 CET 1998
I've recently bought a 266MHz P-II Notebook and installed both
Windows 98 and Redhat Linux on it. And it kicks ass! Maybe I
will get time to completely finishing the last of my
MudOS-alike-for-dgd package. (Mail me for the latest version)
What is left to do, is basically documenting a few more functions
(lost track of what functions I've made man-pages for, mail me if
you got any clever unix-tricks e.g. with grepping to get an
overview over all functions. The files are scattered over several
subdirectory levels). And fix a few "features"/make it better. The
package is very MudOS-oriented in design, and may conflict with
your particular view on how a dgd-system ought to be designed
(read: minimalistic). But its functions are good, and most of them
can be turned off.
My problem: varargs with objects as parameters, and dealing with default
values for objects.
Example: varargs void foo(object bar)
Now the call to this function can happen in four different scenarios:
1) foo()
2) foo(beer) /* when <beer> != 0 */
3) foo(beer) /* when <beer> == 0 */
4) foo(0)
The problem in this example is that there is absolutely NO way in foo()
to detect that <bar> is a default parameter set-to-0 in 1). E.g.
according to the tracelist, scenario 1), 3) and 4) are identical.
This makes functions with default arguments ambigous with functions called
with object variables set to 0, or just the value 0. This is bad
when you both want to trap situations with object-values of 0, AND handle
default values for vararg object-parameters. And there is necessity of
trapping such situations since the values of object variables may change
to 0 without any warning to the current LPC scope.
Should I change all my "varargs foo(object,)"-alike-functions to
"foo(object,)"? Or should DGD change in handling of arguments, e.g. show
how many arguments was REALLY supplied in the tracelist?
The latter seems a better solution, though I don't know if it could break
with existing code. Remember, that there are lots of times you want to
supply "varargs". For example to a function containing several parameters
of mixed types, herein also objects. Then there will be no knowing what is
default, and what is not.
Hmm, this problem (w/solution) also extends to all types it seems. It's
just that you Very rarely have use for a default parameter of
anything != 0.
DGD is a great piece of work btw. My ultimate dream would be LPC
displacing Java.
With Best Regards,
Frank Schmidt
http://www.colargol.tihlde.hist.no/~franks/
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list