MOO-cows Mailing List Archive

[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Ideas about data types



A couple of points:

Firstly, with regard to literals of new data types, I expect that the
best way to implement this would be in the lexical analyzer.  It would 
be fairly simple to call a series of load-time registered functions at 
the end of the lexical analyzer.  The parser would then need to deal
with a generic "literal data" token.  The goal would be to avoid
recompilation of the lexical analyzer, and certainly to avoid
re-lexing and re-yaccing, when adding new data types.

Also, we may want to consider changing the way in which the server
deals with "INT", "FLOAT", etc.  Currently, these are *variables*
automatically created at the beginning of each stack frame.  I think
that "plug-in" data types would be an excellent place to change this
somewhat ugly behavior.

On the issue of operators, I would point out that some MOO operators
are already overloaded (i.e., perform multiple functions depending on
the types of their arguments).  For instance, if '+' gets integers, it 
performs integer addition; with floats, it performs floating point
addition; and with strings, it concatenates.  It would be fairly
simple to allow new data types to register functions for the various
operators.  This could be handled in the guts of run() in a manner
transparent to the parser and to the lexical analyzer...

--Nick

Follow-Ups: References:
Home | Subject Index | Thread Index