[Grace-core] Some notes on pattern matching on the wiki

James Noble kjx at ecs.vuw.ac.nz
Sat Jul 2 23:15:55 PDT 2011


>> var c : CatType
>> c := CatFactory.new("Macavity")
> ??? Where did CatFactory come from?

name of the Factory I guess.. 

> With your definition of Cat (though I'd likely call it CatClass, leaving the shorter name for the type, which would be used more often):
> var c: CatType
> c:= CatClass.new("Kitty")

yep you could do it that way - although I'd be tempted to call the textual _declaration_ the class
and say that it makes a "factory" and a "type" and whatever else...

> Keep in mind that C++ programmers are already forced to specify the signature of the class in a ".h" file before defining the implementation in a ".cc" file.  I'd teach students to write the type first and then copy and paste the spec to write the class.

yep.  and, well generally don't like it - I'm not sure I'd take C++ as an example to emulate.

It's interesting that D & Oberon abandoned the separate specifications from C++ & Modula-2

> As you teach the language, you would first provide students with start-up files that contain the definitions of relevant types and classes, and they would use these to do things.  Then after a week or two, they start defining types and classes themselves.

yep makes sense...

James


More information about the Grace-core mailing list