HaloO,
Juerd wrote:
Can you explain please what "outside-in" means to you?
TSa wrote:
BTW, does everybody expect more than one prefix numerifyer beeing
redundant or is there an idea of (+ (+ @foo)) beeing modelled
Juerd answered:
It's providing context to something that was already providing context.
A bit redundant indeed.
This is exactly what I mean with outside-in. The outer + puts the inner
+ into numeric context and that puts the innermost array in numeric context.
My view is that an array of course knows how many elements it represents.
This is sort of required by the specification of 'a Perl6 Array'.
The prefix + operator is one possibility to retrieve this information
*out of* the array! So is .elems, .size are whatever name is choosen.
Let's assume this number is 42. At what point in a syntactic sequence
outward from the array does this 42 loose its relation to the array @foo?
Compare that to the case where two prefix ops are wrapped around this
number-of-elements retrieval operation in (op1 (op2 (+ @foo))).
Or in the extreme case beeing parametric with respect to all three
operations (&op1 (&op2 (&op3 @foo))). Where is the context generated and
is it propagating inwards, outwards or both?
To me the bottom of the language specification is reached when you hit a
sigiled term or a literal. In the above case this is @foo in (&op3 @foo),
which results in &op3 becoming a prefix op that has to be capable of
handling an array, *without* retrieving any further meta information.
From there I think the type information of the as of the expression itself
unknown return type must be handled by the &op2 and so on until the whole
expression is typed as the return type of &op1. If nothing else is known,
all these type checks or dispatches are deferred until the actual call
and result in an exception if they don't hold.
Sorry if my joke attempt of elems and chars both having a 5 chars name
"symmetry" didn't work. What I want to say is that the other thing that
the language spec has to nail down is the name under which certain, central
concepts are known and how to provide them for non-standard classes,
modules, types or whatever. One means of providing them is MMD. Messing
with the grammar in my eyes is possible but shouldn't be the canonical,
lightweight approach how you add numerification to your class. The same
applies to stringification and with greater difficulty to equality.
This greater difficulty for equality stems from the fact that the concept is
generic with respect to *both* participants while numerification has
a defined result type. Unfortunately the concepts in both cases are not so
well defined either. A string could e.g. numerify to its "length" or by
parsing its "content". I mean +'12' should be twelve not two.
OTOH, +'two' == 2 is not too far fetched.
This obviously is prefix + for numerification. Interestingly, prefix - does
*not* have this redundancy or do you expect the numerical context it imposes
inwards combined with flipping the sign makes (- (- @foo)) <= 0? Or is the
sign flipping honoured with each step inwards but numeric context travels
unhindered once it is established?
--
$TSa.greeting := "HaloO"; # mind the echo!