Fernando Alava | 1 Jul 2008 23:58
Picon

Re: Tuple definition syntax, again

Hi all:

Slava Pestov wrote:

> I still want to redesign the proposed multi-method syntax to avoid the
> | in stack effects, after a recent epiphany regarding the evilness of
> complex lexing rules. Any suggestions there? This seems ugly:
> 
> : nth ( { i integer } { a array } -- elt ) ... ;

What about this?

: nth ( integer array -- elt ) ... ; ! StrongForth-like

The words integer and array are previously defined as valid types.

And if you don't need types you can always write:

: nth ( i a -- elt ) ... ; ! Untyped definition

I think you don't need to specify both i and integer if later you can't
use i as a local variable inside the word definition.

Best regards,
	Fer

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
(Continue reading)

Slava Pestov | 2 Jul 2008 00:09

Re: Tuple definition syntax, again

How would we distinguish between a typed and untyped definition in this case?

Slava

On Tue, Jul 1, 2008 at 4:58 PM, Fernando Alava <fernando.alava <at> gmail.com> wrote:
> What about this?
>
> : nth ( integer array -- elt ) ... ; ! StrongForth-like
>
> The words integer and array are previously defined as valid types.
>
> And if you don't need types you can always write:
>
> : nth ( i a -- elt ) ... ; ! Untyped definition
>
> I think you don't need to specify both i and integer if later you can't
> use i as a local variable inside the word definition.
>
> Best regards,
>        Fer
>
>
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _______________________________________________
> Factor-talk mailing list
(Continue reading)

Fernando Alava | 2 Jul 2008 00:52
Picon

Re: Tuple definition syntax, again

May be that I don't understand the real problem but:

If all the words between ( and -- are known types we got a new typed
definition of a word. In other case the definition is untyped.

Probably attempting to define a new untyped version of a word will issue
an error.

Fer

El mar, 01-07-2008 a las 17:09 -0500, Slava Pestov escribió:
> How would we distinguish between a typed and untyped definition in this case?
> 
> Slava
> 
> On Tue, Jul 1, 2008 at 4:58 PM, Fernando Alava <fernando.alava <at> gmail.com> wrote:
> > What about this?
> >
> > : nth ( integer array -- elt ) ... ; ! StrongForth-like
> >
> > The words integer and array are previously defined as valid types.
> >
> > And if you don't need types you can always write:
> >
> > : nth ( i a -- elt ) ... ; ! Untyped definition
> >
> > I think you don't need to specify both i and integer if later you can't
> > use i as a local variable inside the word definition.

-------------------------------------------------------------------------
(Continue reading)

William Schlieper | 2 Jul 2008 02:30
Picon
Favicon
Gravatar

Re: Tuple definition syntax, again

Fernando Alava wrote:
> May be that I don't understand the real problem but:
> 
> If all the words between ( and -- are known types we got a new typed
> definition of a word. In other case the definition is untyped.
But sometimes we want only part of the parameters to a word to be 
untyped--remember, the primary purpose of typing in word definitions is 
multimethod syntax.

Also, it may be useful to have both a type and a description of what 
you're doing.
> Probably attempting to define a new untyped version of a word will issue
> an error.
> 
> Fer
> 
> El mar, 01-07-2008 a las 17:09 -0500, Slava Pestov escribió:
>> How would we distinguish between a typed and untyped definition in this case?
>>
>> Slava
>>
>> On Tue, Jul 1, 2008 at 4:58 PM, Fernando Alava <fernando.alava <at> gmail.com> wrote:
>>> What about this?
>>>
>>> : nth ( integer array -- elt ) ... ; ! StrongForth-like
>>>
>>> The words integer and array are previously defined as valid types.
>>>
>>> And if you don't need types you can always write:
>>>
(Continue reading)

Eduardo Cavazos | 2 Jul 2008 03:36
Picon

Re: Tuple definition syntax, again

On Tuesday 01 July 2008 19:30:02 William Schlieper wrote:

> But sometimes we want only part of the parameters to a word to be
> untyped--remember, the primary purpose of typing in word definitions is
> multimethod syntax.

You can declare those paramters 'object', which is the sort of catch all type.

> Also, it may be useful to have both a type and a description of what
> you're doing.

That right there is the issue. It's nice for the documentation to reference 
the parameter names specified in the effect.

Ed

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
Eduardo Cavazos | 2 Jul 2008 04:10
Picon

Re: Tuple definition syntax, again

On Sunday 29 June 2008 23:32:03 Slava Pestov wrote:

> I still want to redesign the proposed multi-method syntax to avoid the | in
> stack effects, after a recent epiphany regarding the evilness of complex
> lexing rules. Any suggestions there? This seems ugly:
> : nth ( { i integer } { a array } -- elt ) ... ;

Was the complex lexing rules issue bad enough such that you won't consider the

        parmeter:type

style at all? I.e. have you definately given up on that idea?

I don't think you're going to get around the fact that this is the best syntax 
for the problem at hand.

Another style similar to old school C is where you put the types in a separate 
place:

	: nth ( i seq -- elt )
	  ...
	  ... ; ( integer sequence -- object )

I.e. the type annotation goes in a separate place.

I would have thought that it would be pretty easy to expand:

	a:object

into some canonical form like
(Continue reading)

Crest da Zoltral | 2 Jul 2008 12:13
Picon

Re: Tuple definition syntax, again


Am 02.07.2008 um 00:09 schrieb Slava Pestov:

How would we distinguish between a typed and untyped definition in this case?

Slava

On Tue, Jul 1, 2008 at 4:58 PM, Fernando Alava <fernando.alava-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
What about this?

: nth ( integer array -- elt ) ... ; ! StrongForth-like

The words integer and array are previously defined as valid types.

But what if elt is later defined later as a type?

And if you don't need types you can always write:

: nth ( i a -- elt ) ... ; ! Untyped definition

Again this only works unless somebody lazy enought to use one char long names for his types defines them in the same vocabulary breaking code he didn't modifiy.

I think you don't need to specify both i and integer if later you can't
use i as a local variable inside the word definition.

: mod ( integer integer -- integer ) ... ;
Is non commutative and all inputs and outputs are integers here someone not knowning the order the paramerters are expected to be in would benefit from a useful description.  

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Eduardo Cavazos | 2 Jul 2008 17:36
Picon

baking and frying

Hello,

The 'bake' vocabulary has been revisited.

Baking is like frying, but it's for arrays.

	10 20 30 `{ , , , }
=>
	{ 10 20 30 }

	10 { 21 22 23 } 30 `{ , , , }
=>
	{ 10 { 21 22 23 } 30 }

	10 { 21 22 23 } 30 `{ ,  <at>  , }
=>
	{ 10 21 22 23 30 }

Bake has been changed so that the elements are "baked" in order, just like 
fry.

Bake is now much more efficient. It is a macro which generates code which will 
construct the array at runtime.

Fry offers three directives: ,  <at>  _. Bake only supports the , and  <at> . The '_' 
isn't applicable to arrays.

Ed

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
William Tanksley, Jr | 2 Jul 2008 19:00
Picon

Re: baking and frying

Eduardo Cavazos <wayo.cavazos@...> wrote:
> The 'bake' vocabulary has been revisited.
> Baking is like frying, but it's for arrays.

Sounds yummy.

>        10 { 21 22 23 } 30 `{ , , , }
> =>
>        { 10 { 21 22 23 } 30 }
>        10 { 21 22 23 } 30 `{ ,  <at>  , }
> =>
>        { 10 21 22 23 30 }

Nice examples.

> Fry offers three directives: ,  <at>  _. Bake only supports the , and  <at> . The '_'
> isn't applicable to arrays.

What does _ do when frying? (I tried to figure this out when you first
announced it, but the only source of info at the time was building my
own Factor and reading the help, and that just took to long.)

> Ed

-Wm

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
Joe Groff | 2 Jul 2008 19:10
Picon
Gravatar

Re: baking and frying

> 	10 20 30 `{ , , , }
> =>
> 	{ 10 20 30 }
>
>
> 	10 { 21 22 23 } 30 `{ , , , }
> =>
> 	{ 10 { 21 22 23 } 30 }
>
>
> 	10 { 21 22 23 } 30 `{ ,  <at>  , }
> =>
> 	{ 10 21 22 23 30 }

Out of curiosity, why do you use backtick in bake (`{) but apostrophe  
in fry ('[)?

-Joe

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08

Gmane