Related articles |
---|
Calculating expressions with several types div@infonet.nnov.ru (=?koi8-r?B?4c7Uz84=?=) (2000-12-11) |
Re: Calculating expressions with several types lgcl01@es.co.nz (Fairbairn Family) (2000-12-13) |
Re: Calculating expressions with several types chris@cjl1.demon.co.uk (Chris Locke) (2000-12-13) |
Re: Calculating expressions with several types jparis11@home.com (Jean Pariseau) (2000-12-18) |
From: | "Chris Locke" <chris@cjl1.demon.co.uk> |
Newsgroups: | comp.compilers |
Date: | 13 Dec 2000 15:04:07 -0500 |
Organization: | Compilers Central |
References: | 00-12-044 |
Keywords: | types |
Posted-Date: | 13 Dec 2000 15:04:07 EST |
You may find the ECMAscript (Javascript) standard interesting. seek
out ECMA-262 at http://www.ecma.ch/
It gives procedural semantics for evaluation of expressions. It
defines (in its own odd way!) what conversions should be applied at a
particular time when parsing and evaluating expressions.
I'm not a fan of JavaScript or its type system. But if you have never
looked at implementing this sort of stuff before it might be
interesting to see what's involved.
Javascript uses what some term a 'Variant' type system where objects
are fairly type anonymous until an explicit value type is required, at
which time type conversion is carried out. Fom your original post it
sounded as if this is the sort of thing you are after. Internally,
objects are carried around in a union with a tag indicating the active
type and corresponding field of the union. New objects are created
with a nul type and value, with appropriate conversion rules. (e.g
nul type converts to the empty string)
Once you get into the area of converting to/from strings you have to
start defining a whole bunch of supported notations e.g. do you
support hexadecimal numbers in String -> Number conversions? What is
the format? Will round-trip conversions (e.g. String -> Number ->
String) yield consistent results. The ECMA-262 standard has to go
into those sorts of details! Depending on what your language is for,
you may not have too go into such detail.
Chris.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.