Ed,
I tested the behavior of both examples before sending my previous e-mail.
To clarify, the following defines a tuple class 'foo' with a slot
named 'a' whose type is constrained to be the 'read-only' class:
IN: foo
TUPLE: read-only ;
TUPLE: foo { a read-only } ;
ie, a>> on instances of 'foo' always puts a foo:read-only instance on the stack.
The following defines a tuple with a slot named 'a' whose value cannot
be changed:
IN: foo
TUPLE: read-only ;
USE: syntax
TUPLE: foo { a read-only } ;
Does this clear up the confusion? syntax:read-only is a symbol and
TUPLE: looks for this symbol. If you define your own word (tuple class
or otherwise) named read-only, it will shadow syntax:read-only unless
you resolve the shadowing as I did above with USE: syntax.
This is just another manifestation of this phenomenon:
IN: foo
: [ "HAHA" print ;
[ 1 2 3 ] ! oops, that might not be what I meant...
Slava
On Wed, Dec 3, 2008 at 1:52 AM, Eduardo Cavazos <[EMAIL PROTECTED]> wrote:
> Slava Pestov wrote:
>
>> Is your new read-only word shadowing the one in syntax?
>>
>> TUPLE: read-only ;
>> USE: syntax
>> TUPLE: abc { a read-only } ;
>>
>> should work fine.
>
> Try the example in my note.
>
> The documentation says that the slot attribute specifier is "one of initial:
> or read-only". However, TUPLE: seems to allow both to be specified
> simulataneously. This is what breaks when you define a 'read-only' class in
> any vocabulary.
>
> Ed
>
>> On Wed, Dec 3, 2008 at 1:35 AM, Eduardo Cavazos <[EMAIL PROTECTED]>
> wrote:
>> > Slava,
>> >
>> > This:
>> >
>> > TUPLE: read-only ;
>> >
>> > Breaks the 'read-only' attribute. I.e. these won't work after a
>> > 'read-only' class is defined:
>> >
>> > TUPLE: <abc> { a read-only initial: 10 } ;
>> >
>> > 10 <abc> boa
>> >
>> > Ed
>> >
>> > -------------------------------------------------------------------------
>> > This SF.Net email is sponsored by the Moblin Your Move Developer's
>> > challenge Build the coolest Linux based applications with Moblin SDK &
>> > win great prizes Grand prize is a trip for two to an Open Source event
>> > anywhere in the world
>> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> > _______________________________________________
>> > Factor-talk mailing list
>> > [email protected]
>> > https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge Build the coolest Linux based applications with Moblin SDK & win
>> great prizes Grand prize is a trip for two to an Open Source event anywhere
>> in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Factor-talk mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk