Type Parameters are Completely Unnecessary

Darryl psygnisfive at yahoo.com
Tue Mar 4 23:00:13 PST 2008

*Note: whoops, I accidental replied to sender not to
the list. Sorry.

<< Arguments to a constructor can't be type terms, so
can't be used in  annotations, so can't be
type-checked. You must mean manual, runtime  "type"
checking by typeof, instanceof, or other tests. That's
not what type checking means in the context of type
parameters. >>

I understand that it's different than run-time type
checking, but the question is the necessity of this
sort of thing as a feature of syntax.

<< I suggest focusing on semantics and setting aside
syntactic issues  
for a bit. If you just don't want optional types
anywhere, then why  
pick on type params? >>

Optional types are fine, but I think including
something in syntax should only occur if it's
necessary, and I don't see it as being necessary given
the fact that type checking exists within the
language. Given that things like strings and arrays
and such are all classes, passing that is what I had
in mind. For instance, off the top of my head,

var numberSet = new TypedSet(Number);

which has an add method like

    if( obj instanceof Number ){
        //add it

As it is, I find

var numberSet = new Set.<Number>();

to be incredibly ugly and I'm one of those Code Should
Be Beautiful sorts, so this is a huge problem for me.
I'd go so far as to say that because "types" are
classes (afaik), there should be absolutely no reason
you can't refer to types.


Also, consider this: Suppose I want a set that
EXCLUDES a certain type? Do we need special syntax for
this too? <!type> maybe? If it were just a parameter,
then a coy little generic "not" function could exist
that wraps a class in an object, like say Not(Number)
= { kind: "not", value: Number }, as in
TypedSet(Not(Number)), so that add can now see that
the class is wrapped in a not that excludes it, rather
than requires it. This is a trivial thing to do if
your set-content-type is defined through existing
methods, but becomes tricky if you have to do special
syntax for it.

And then I might go on to say, well why not just have
syntax for this and syntax for that and lets put
_everything_ in syntax and nevermind actually using
the language to build stuff the language should _be_
that stuff. My contention is that you don't NEED typed
parameters, they don't add much utility and certain
detract from aesthetics, and they aren't really core
conceptual features of what these classes are, they're
extensions on the notion of what they do.


Be seeing you...

Never miss a thing.  Make Yahoo your home page. 

More information about the Es4-discuss mailing list