I was looking for a definition.  "quot:" does not seem to behave like a word
or literal.  "quot:" occurs only once on the above page in an example of a
row-polymorphic combinator, but is not defined.  However, "quot" is
mentioned briefly in the table of 13 "names":

There's no documentation for "quot:" because, just like other names in a
stack effect without the colon, the name "quot" doesn't mean anything except
as documentation for the human reader.

 

Yes, that is the part that concerns me.  Why did we design this convention?

 

The ":" at the end indicates that it's followed by a nested stack effect
declaration. From the linked "Stack effects" documentation:

 

--

Parameters which are quotations can be declared by suffixing the parameter
name with : and then writing a nested stack effect declaration.

--

Yes, I saw that but don't like it.  Is there way to use Factor productively
without this convention?

 

 

A word could be defined with the following stack effects and the behavior
would be the same:

 

--

: foo ( a quot -- )

: foo ( apples bananas -- )

: foo ( !...@# @#$ -- )

--

 

Likewise, with nested stack effect checking, the following are equivalent:

 

--

: bar ( a quot: ( b -- ) -- )

: bar ( apples bananas: ( pears -- ) -- )

: bar ( !...@# @#$: ( #$% -- ) -- )

--

 

The point of these examples seems to be that the tokens appearing in the
stack-effect syntax are truly arbitrary, but how then are the stack-effects
count- and type-binding?  Ignore for now the fact that you can declare
nested effects.  Take the basic case.  What if I really want word
sum-of-integers to be able to add only integers and not, say, floats?:

 

: sum-of-integers ( integer integer -- integer )  

    + ;

 

In the above definition, I want the references to integer to be real
references to class integer, as a type of the instance expected in the
corresponding stack position.  I want to say what I mean, mean what I say,
and be held accountable by the compiler for all it, but I don't see that
happening in the examples, unless apples and bananas, for instance, are real
classes, and not just surrogates.

 

I don't see the utility of the scheme.  I just want to define the number,
position, and types of inputs and outputs for a word.

 

 

Shaping

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to