Eduardo Cavazos | 1 Dec 2008 01:05
Picon

Re: Class names

Doug Coleman wrote:

> I guess what I meant was "syntactic sugar creep"

Consistent conventions cure cancer of the quote

:-)

-------------------------------------------------------------------------
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=/
Alex Chapman | 1 Dec 2008 01:19
Picon

Re: Class names

Hi,

I just realized there are two issues here.

1) Having a convention for class names
2) Making it safe to define words that shadow class names

I'm not really interested in 1) because it doesn't seem useful to me
to know that something if something is a class or not.  Mousing over a
word will tell you that.  Also, most of the time, a class name is
followed by new or boa, or this is encapsulated in a constructor.

I think a better distinction is "inert word" or "live explosive
word".  In this vein, it would make sense to find a single syntax for
this, which is what \ does for symbols, word names, and class
names.    If you're passing around classes to be constructed later,
then I think just knowing they're inert and having "class" in the
stack effect is enough.

We have several types of symbol-like things in Factor. First we have symbols. These are a bit like common-lisp symbols, except that they must be manually interned, and they are executable. When executed they simply push themselves:

SYMBOL: foo
foo .
  => foo
\ foo .
  => foo
foo execute .
  => foo

Next we have tuple classes. I haven't looked into the implementation, but these seem to be semantically equivalent to symbols:

TUPLE: bar ;
bar .
  => bar
\ bar .
  => bar
bar execute .
  => bar

And then we have words. These are also symbols, but when executed they do something arbitrary. This could include pushing their own symbol, so in a way symbols are a subset of words:

: blah ( -- symbol ) \ blah ;
blah .
  => blah
\ blah .
  => blah
blah execute .
  => blah

I think the core of Ed's complaint was that symbols quote themselves implicitly, rather than requiring an explicit \, which leads to code that reads inconsistently. Worse than this, it means that the behaviour of code can change when a new vocab is USEd, because tuple class symbols push themselves up until a word is defined with the same name.

A more general version of this problem is: Should adding a vocab to your USING statement (or a change in a USEd vocab) ever change the behaviour of your program?

I don't think it should, and always using an explicit \ is one way of ensuring this. Of course, we can put our IN: below our USING: so that anything we define takes precedence over anything USEd, but this is a bit of a hack. It doesn't work consistently when we're experimenting in the listener, and any vocab using our vocab has to put our vocab last (or is it first?) in their USING: statement if they want to use our unquoted symbol rather than the other vocab's conflicting word.

Alex
-------------------------------------------------------------------------
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
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Eduardo Cavazos | 1 Dec 2008 01:22
Picon

with-slots

Slava,

Didn't you once say that a 'with-slots' word for binding slot values to names 
in a given block is something you though would be nice?

I just now ran into some code where I think it would help.

Are you still interested in that idiom? It would be a nice way to employ 
tuples where locals might normally be used.

I suppose that it's essentially a shorthand for a 'let' which extracts and 
bind the slots appropriately.

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=/
Alex Chapman | 1 Dec 2008 01:28
Picon

UNUSE:?

Hi All,

Sometimes using the listener I'll accidentally USE the wrong vocab to get a word I want. Is there any way to un-USE this vocab? Often the quickest way is to quit Factor and start again (or start a new listener), but that's ugly. What I'd like is a way to continuously use a listener session, and be able to control its state by adding a removing vocabs.

Thanks,

Alex

-------------------------------------------------------------------------
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
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Slava Pestov | 1 Dec 2008 01:28

Re: with-slots

: with-slots ( tuple quot -- ) [ <mirror> ] dip bind ; inline

On Sun, Nov 30, 2008 at 6:22 PM, Eduardo Cavazos
<wayo.cavazos@...> wrote:
> Slava,
>
> Didn't you once say that a 'with-slots' word for binding slot values to names
> in a given block is something you though would be nice?
>
> I just now ran into some code where I think it would help.
>
> Are you still interested in that idiom? It would be a nice way to employ
> tuples where locals might normally be used.
>
> I suppose that it's essentially a shorthand for a 'let' which extracts and
> bind the slots appropriately.
>
> 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
> Factor-talk@...
> 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=/
Slava Pestov | 1 Dec 2008 01:30

Re: UNUSE:?

: UNUSE: scan vocab-words use get delq ; parsing

On Sun, Nov 30, 2008 at 6:28 PM, Alex Chapman <chapman.alex@...> wrote:
> Hi All,
>
> Sometimes using the listener I'll accidentally USE the wrong vocab to get a
> word I want. Is there any way to un-USE this vocab? Often the quickest way
> is to quit Factor and start again (or start a new listener), but that's
> ugly. What I'd like is a way to continuously use a listener session, and be
> able to control its state by adding a removing vocabs.
>
> Thanks,
>
> Alex
>
> -------------------------------------------------------------------------
> 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
> Factor-talk@...
> 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=/
Doug Coleman | 1 Dec 2008 01:30
Picon

Re: Class names

> I think the core of Ed's complaint was that symbols quote themselves  
> implicitly, rather than requiring an explicit \, which leads to code  
> that reads inconsistently. Worse than this, it means that the  
> behaviour of code can change when a new vocab is USEd, because tuple  
> class symbols push themselves up until a word is defined with the  
> same name.
>
> A more general version of this problem is: Should adding a vocab to  
> your USING statement (or a change in a USEd vocab) ever change the  
> behaviour of your program?

I agree that it shouldn't.  A similar problem comes up when lines of  
code are coupled together, like when you have a TUPLE: class and you  
suddenly make a new word that shadows this -- it's bad design to have  
to edit all the places where you haven't already escaped this word.   
Touching one line of code and having to edit ten places that depended  
on that line is one thing Factor tries to avoid.  Factor's GENERIC:  
words are a good example -- you don't have to edit the file that  
defines the GENERIC:, just add a method.  Code that is coupled to  
other code is bad.

Doug

-------------------------------------------------------------------------
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=/
Eduardo Cavazos | 1 Dec 2008 01:32
Picon

Re: Class names

On Sunday 30 November 2008 18:19:44 Alex Chapman wrote:

> And then we have words. These are also symbols, but when executed they do
> something arbitrary. This could include pushing their own symbol

Yup. In fact, here's something which I found surprising the first time I ran 
into it:

    : a \ a ;

    \ a symbol?     --->     t

I.e. even though you don't use SYMBOL: to define 'a', it's still a symbol. :-)

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=/
Slava Pestov | 1 Dec 2008 01:33

Re: Class names

On Sun, Nov 30, 2008 at 6:19 PM, Alex Chapman <chapman.alex@...> wrote:
> And then we have words. These are also symbols, but when executed they do
> something arbitrary. This could include pushing their own symbol, so in a
> way symbols are a subset of words:

All of the things you described (symbols, classes) are also words.

> A more general version of this problem is: Should adding a vocab to your
> USING statement (or a change in a USEd vocab) ever change the behaviour of
> your program?

This is completely orthogonal to the issue at hand.

> I don't think it should, and always using an explicit \ is one way of
> ensuring this.

Using \ explicitly does not ensure this at all. Consider you have this code:

IN: a
: foo "lol" throw ;

IN: b
TUPLE: foo x y z ;

Now this program:

IN: c
USING: a b ;

: bar ... \ foo ... ;

is not the same as this program:

IN: c
USING: b a ;

: bar ... \ foo ... ;

Even though both foo's are quoted using \.

> Of course, we can put our IN: below our USING: so that
> anything we define takes precedence over anything USEd, but this is a bit of
> a hack. It doesn't work consistently when we're experimenting in the
> listener, and any vocab using our vocab has to put our vocab last (or is it
> first?) in their USING: statement if they want to use our unquoted symbol
> rather than the other vocab's conflicting word.

If you want, you can use the qualified vocabulary's FROM: word to
explicitly control what words are imported.

FROM: sequences => each reverse ;
FROM: math => + - ;
IN: my-vocab

...

Slava

-------------------------------------------------------------------------
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=/
Alex Chapman | 1 Dec 2008 01:35
Picon

Re: UNUSE:?

Great :)

Any chance you'll be adding that to the syntax vocab?

2008/12/1 Slava Pestov <slava-ZiOttN0IXrP2JYTphGNI2Q@public.gmane.org>
: UNUSE: scan vocab-words use get delq ; parsing

On Sun, Nov 30, 2008 at 6:28 PM, Alex Chapman <chapman.alex-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hi All,
>
> Sometimes using the listener I'll accidentally USE the wrong vocab to get a
> word I want. Is there any way to un-USE this vocab? Often the quickest way
> is to quit Factor and start again (or start a new listener), but that's
> ugly. What I'd like is a way to continuously use a listener session, and be
> able to control its state by adding a removing vocabs.
>
> Thanks,
>
> Alex
>
> -------------------------------------------------------------------------
> 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
> Factor-talk-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> 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
Factor-talk-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
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
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk

Gmane