[Grace-core] Fwd: Query on built-in objects

James Noble kjx at ecs.vuw.ac.nz
Tue Jun 19 04:34:37 PDT 2012


> So I can take both the operator's implicit asString call and the
> implementations on non-Strings (which I didn't realise were there) out?

the other thing is to have in mind is that most of these 
things should be able to be added or extended via "dialects"

the Standard Prelude is a good start here; some way of indicating
*which* prelude to compile against would be the next step;
(ideally in the source - #lang or somthing - rather than a switch)
Hopefully the module system will have a coherent explanation
and semantics of all this (i.e. family-poly style, inheriting
from the existing prelude *object* and (re)defininig things in there).
the code below works as expected - the "class version" further below doesn't.

there would also need to be some way / convention / rule
for working out which classes literals & etc belong
and (unfortunately) restrictions to ensue things don't get too weird
e.g. ensuring only one definition of String per program?

//////////////////////////////////////////


print "Hello, world!"

method dynamic (o : Dynamic) -> Dynamic {o} 

class Standard.new {
  method Widget'new  {
     print "creating Standard.Widget"
     return object {
        def foo = "SWi.foo"
        def bar = "SWi.bar"
        def myWodget = Wodget'new
   } }
  method Wodget'new {
     print "creating Standard.Wodget"
     return object {
       def foo = "SWo.foo"
       def bar = "SWo.bar"
  } }
  def a = Widget'new
  def b = Wodget'new
  print (a.foo)
  print (a.bar)
  print (a.myWodget.foo)
  print (b.foo)
  print (b.bar)
}

class Dialect.new {
 inherits Standard.new
   method Wodget'new {
     print "creating Dialect.Wodget"
     return object {
       inherits super.Wodget'new
       def foo = "DWo.foo"
   } }

   def a = Widget'new
   def b = Wodget'new
   print (a.foo)
   print (a.bar)
   print (a.myWodget.foo)
   print (b.foo)
   print (b.bar)
}


Standard.new 

Dialect.new

print "done"


//////////////////////////////////////////



print "Hello, world!"

class Standard.new {
   class Widget.new {
     print "creating Standard.Widget"
     def foo = "SWi.foo"
     def bar = "SWi.bar"
   }
   class Wodget.new {
     print "creating Standard.Wodget"
     def foo = "SWo.foo"
     def bar = "SWo.bar"
   }
   def a = Widget.new
   def b = Wodget.new
   print (a.foo)
   print (a.bar)
   print (b.foo)
   print (b.bar)
}

class Dialect.new {
 inherits Standard.new
   class Wodget.new {
//     inherits super.Wodget.new
     print "creating Dialect.Wodget"
     def foo = "DWo.foo"
   }

//   def a = Widget.new
   def b = Wodget.new
   print (a.foo)
//   print (a.bar)
   print (b.foo)
//   print (b.bar)

}


Standard.new 

Dialect.new

print "done"




More information about the Grace-core mailing list