Re: lua 3.0a tag methods

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: lua 3.0a tag methods

Mark Ian Barlow
In message <[hidden email]> Roberto wrote:
 > 
 >   I will try a quick explanation. I hope that will be enough for a start.
<snip>
 > This is the hardest part. The general idea: internal methods (or tag
 > methods, or just fallbacks :-) is mainly the old concept of fallbacks,
 > with one big, and some small differences:
 > 
 > + instead of being globally defined, each tag can have its own set of methods. 
 > - like userdata, tables can have different tags.
 > - to use tag methods, tags must be explicitly created with "newtag".
 > - tables now also have tag methods for gettable and settable.
<snip>
 > Other details:
 > 
 > - fallback 'arith' has been splited in many tag methods: 'add', 'sub',
 > 'mul', etc. The same for 'order'.
 > 
 > - since userdata are immutable, you cannot use "settag" for them. Instead,
 > they must be created with their final tag.
 > 
 > - old tags (user defined, without using newtag) can still be used, but
 > you cannot associate a tag method to them.
<snip>

This looks like a very powerful enhancement. It seems a shame (IMHO) to use
such a small word as 'tag' to describe it; tags as described seem to confer
membership of a sort of "meta class" or "exception interface" (interface in
the java sense). Despite their relative simplicity as seen from the user's
point of view, this is not a trivial concept!

Objects with the same tag, it seems, may share common exception handling,
inheritance mechanisms and a host of other possible behaviours. There is
some confusion with userdata tags, which merely implement (optional) user
controlled type checking. Perhaps we need to distinguish better between
the two?

Words like 'class', 'interface' and 'type' are already loaded down with
meanings from other languages, none of which quite fits what we have here,
but there are plenty of others left which express the concept of membership
of some larger group, A quick trawl through Roget's thesaurus yielded the
following (selected on no particular basis):

species phylum family genus caste category taxon(?) ilk(!) ...

I think I like 'species' best, it conveys the idea of something evolved and
adapted to cope with a particular (ecological) niche...

Ok, so this has all been a bit of a quibble over nomenclature but I think
Lua's authors really have something quite new here; is it species-oriented
programming?

--  Mark Ian Barlow                Non-Linear Control Consultants Ltd.
    -----------------------------------------------------------------
    [hidden email]            Voice / Fax: +44 (0)1207 562 154

Reply | Threaded
Open this post in threaded view
|

Re: lua 3.0a tag methods

Luiz Henrique de Figueiredo-2
>This looks like a very powerful enhancement.

it's powerful, but really "only" a cleaned-up fallback concept.
i think the fallback concept is the really powerful construct.
prior to 3.0, fallbacks were global and had to be chained (with hard-to-predict
iterations).
with 3.0 and tag methods, fallbacks are now local to object families.

>It seems a shame (IMHO) to use
>such a small word as 'tag' to describe it; tags as described seem to confer
>membership of a sort of "meta class" or "exception interface" (interface in

well, english is not our first language. we may be missing some of the
more subtle meanings of the word "tag".
we certainly do not want 'class' or 'type' because these seem to imply some
kind of checking or hard type system, which Lua does not have.
to us, from the beginning, "tag" was just something that the user gave to an
object (originally, only userdata) so that he could treat different objects
in different ways. i think this meaning is still valid.

>species phylum family genus caste category taxon(?) ilk(!) ...
>
>I think I like 'species' best, it conveys the idea of something evolved and
>adapted to cope with a particular (ecological) niche...

i prefer 'family', but this would give very long names in the API...

>Ok, so this has all been a bit of a quibble over nomenclature but I think
>Lua's authors really have something quite new here; is it species-oriented
>programming?

I agree. methods attached to "tags", which can be dynamically changed (both
methods and tags), are really powerful.
I hope that you will help us show how.
--lhf

Reply | Threaded
Open this post in threaded view
|

Re: lua 3.0a tag methods

Norman Ramsey-3
The tag stuff vaguely reminds of stuff Dave Hanson did with event
mechanisms in Snobol about 20 years ago.  I haven't read the papers
in a long time, but they appeared in Software---Practice and
Experience.

Norman

@article{line2106,
author="David R. Hanson",
title="Event Associations in {SNOBOL4} for Program Debugging",
journal=SPE,
volume=8, number=2, pages="115-129", month=mar, year=1978
}

@article{hanson76,
author="David R. Hanson",
title="Variable Associations in {SNOBOL4}",
journal=SPE,
volume=6, number=2, pages="245-254", month=apr, year=1976
}

Reply | Threaded
Open this post in threaded view
|

Re: lua 3.0a tag methods

Roberto Ierusalimschy
In reply to this post by Mark Ian Barlow
In message <990@...> Mark wrote:
> There is
> some confusion with userdata tags, which merely implement (optional) user
> controlled type checking. Perhaps we need to distinguish better between
> the two? 

Notice that now these two concepts will merge in one. The tag that controls
methods *is* the tag the user can use to control type checking. (In fact, I
think that was the main reason to keep the name "tag"). The new
function "createtag" is supposed to help this other use too, since currently
two different libraries can choose the same tag for different meanings.
That is, "createtag" gives a discipline to tags that is usefull even when
you do not use methods.

-- Roberto