[Prev][Next][Index][Thread]

# Re: Alternate approach to Verbifying properties

- Date: Thu, 25 Jul 1996 11:47:33 PDT
- From:
- Content-Type: text/plain; charset="us-ascii"

    At 10:29 AM 7/25/96 PDT, it was mentioned:
    >Someone (on moo-cows) suggested:
    >>If there are to be synyax changed, I would rather like see obj.foo = bar;
    >>to implicitely call set_property_value(obj, "foo", bar), so a wrappers
    >>assignement on property assignement. (and of course bar = obj.foo; would do
    >>an implicit call to property_value(obj, "foo")...
    >
    >In my opinion, having this exact way would be a bottleneck on the server.
    >I would support the idea of having a call like:
    >
    >define_property_verbs(obj,"prop",verblist);
    >where verblist is:
    >{
    >  {dispatchobj,"typeofverb"},  // verb called when: typeof(obj.prop)
    >  {dispatchobj,"tostrverb"},   // verb called when: tostr(obj.prop)
    >  {dispatchobj,"toobjverb"},   // verb called when: toobj(obj.prop)
    >  {dispatchobj,"tonumverb"},   // verb called when: tonum(obj.prop)
    >  {dispatchobj,"tointverb"},   // verb called when: toint(obj.prop)
    >  {dispatchobj,"tofloatvb"},   // verb called when: tofloat(obj.prop)
    >  {dispatchobj,"clearprop"},   // verb called when: clear_property(obj,"prop")
    >  {dispatchobj,"recyclevb"},   // verb called when: object is recycled
    >  {dispatchobj,"initialise"},  // verb called when: obj.prop = expr;
    >  {dispatchobj,"initindex"},   // verb called when: obj.prop[expr] = expr;
    >  {dispatchobj,"initidxrng"},  // verb called when: obj.prop[expr..expr]=expr;
    >  {dispatchobj,"updateverb"},  // verb called when: obj.prop = expr;
    >  {dispatchobj,"updateindex"}, // verb called when: obj.prop[expr] = expr;
    >  {dispatchobj,"updatidxrng"}, // verb called when: obj.prop[expr..expr]=expr;
    >  {dispatchobj,"retrieveverb"},// verb called when: var= obj.prop;
    >  {dispatchobj,"indexverb"},   // verb called when: obj.prop[expr]
    >  {dispatchobj,"idxrangeverb"},// verb called when: obj.prop[expr..expr]
    >  {dispatchobj,"spliceverb"}   // verb called when: @obj.prop;
    >  {dispatchobj,"spliceindex"}, // verb called when: @obj.prop[expr]
    >  {dispatchobj,"spliceidxrng"},// verb called when: @obj.prop[expr..expr]
    >})

    A possible problem I see is that all of these operations (with the exception
    of clear_property) operate on expressions when the property reference is on
    the rhs.  The method that is used to generate code would have to change from
    treating property references as direct expressions to one that treated
    property references as a special syntax.

    Note that:

      x = this.prop;
      y = tofloat(x);

    is exactly the same as:

      y = tofloat(this.prop);

    As far as tofloat is concerned, it is receiving a value, not a property
    reference.  If you use the first case, then the code that would be generated
    could not tell that x actually contains the result of a property reference.
    Not that this couldn't be changed, but it will make the parser and code
    compiler/decompiler overly complicated.  Perl operates like this in some
    cases, and it makes it extremely compilcated to use for newcomers to
    programming (of course, MOO is a stack based language, it doesn't seem that
    perl is).  Ever look at the source code for perl? :) :)

    Andy.

- Prev: Alternate approach to Verbifying properties
- Next: Re: Alternate approach to Verbifying properties
- Index: MOO-cows
- Thread: MOO-cows

Home | Subject Index | Thread Index