String is open and dynamic!

# P T Withington (18 years ago)

I was just about to ask if I would be able to subclass String in es4,
and I find I can! Hurray!

(Because the OpenLaszlo debugger creates 'annotated' strings with its
printf method that remember the objects associated with each string
representation. I have to kludge this in es3 because these annotated
strings are not instances of String...)

# Lars T Hansen (18 years ago)

You can subclass "String" but not "string", and the latter is not a subclass of the former, which is just a container class. So I might not open the Champagne quite yet, if I were you.

# P T Withington (18 years ago)

Oh right. I hate primitive types. Everywhere in my code I have to say:

typeof x == 'string' || x instanceof String

Will this get any better in es4? I seem to recall that Dylan somehow
kept Number open but sealed Integer and Float so you could have
competitive numeric performance and still permit a user throwing in a
Complex library. Couldn't string be a sealed subclass of String so I
can be generic if I use String, or I can restrict myself to string
and be fast?