« first day (2272 days earlier)      last day (1508 days later) » 

12:05 AM
I am not at all convinced that the reason 1 + 2 * 3 is written that way is due to a desire to have a shorter stack depth than multiply add 1 2 3 ("because you never have a multiplication and an addition on the stack at the same time"). :-/ It seems to me that people with such concerns should be using a stack-based evaluation dialect where they have complete control, vs. wiring infix funny to sort-of get that.
 
1:01 AM
@HostileFork Please see shift-reduce parser.
"suppression of lookahead while evaluating right hand side arguments without quoting" has got to be the best definition of "reduction" I have ever seen.
I myself have refrained from begging you to use the correct term, yours is also good.
And lastly, the problem is not with "chains of arithmetic", but with "readability and efficiency of expression".
 
Well it's not a parser.
 
@HostileFork Negation is not argument ... what is it doing that is not parsing ...
 
The implementation not only doesn't build trees, but it has a lookahead and lookback mechanism that is peculiar to it, can change rules as the expression is evaluated, etc.
 
Treeness is not essential to parsing.
Dealing with the priority (precedence) of operators is.
 
That Wikipedia example doesn't have anything to do with evaluation. In any case, I guess I now understand what your issue is, but I just think it's barking up the wrong tree.
 
1:06 AM
Yes, Rebol has a unique way of implementing dynamic shift-reduce parsing, but that is what it is doing, exactly.
 
The fact is that Rebol is going to be a poor arithmetic evaluator as an interpreter when it comes to performance, pretty much however you slice it, relative to other approaches.
I looked into the approach where add 1 2 * 3 would run the multiplication after the add "because it could", and add 1 * 2 3 would not be able to so it wouldn't, and the reason I wound up not liking it is the same reason I don't care for this infix trick--the variability.
 
@HostileFork Not stack-overflowingly poorly. Not "even small expressions allocate and release stack space" poorly.
And again, it is not arithmetic that we are talking about!!!!
Well, OK, arithmetic is a good example.
But I envisage much, much, MUCH more, like append operators, etc.
And knowing that the operators use the value on the left rather than the expression on the left is invaluable (ha ha) in readability.
 
Well, the non-quoting form is effectively left to right, because it forces completion to the left.
You just can't use it as the argument to things, because I don't like the "greedy until it stops" arbitraryness.
>> +: enfix :add
== make function! [[value1 value2 return:]]

>> *: enfix :multiply
== make function! [[value1 value2 return:]]

>> =: enfix :equal?
== make function! [[value1 value2 return:]]

>> 1 + 2 * 3
== 9

>> 1 + 2 * 3 = 9
== true
The problem is that it won't allow you to say if 1 + 2 * 3 = 9 [...] without parentheses.
The reason being to avoid that "slip" on the last argument.
@MarkI So if your complex operators you're thinking of are more like <| and |> than they are like + or *, they would be covered by the non-quoting left arg form.
You just have to parenthesize their net result.
 
My infix operators use values, not expressions, on the left. If I need that, the parentheses take care of pointing out how far backwards the code-reader's eyes have to scan.
And yes, that means that "value operator value operator value" is just a value. It is mentally as well as evaluatively reduced.
 
1:21 AM
@MarkI That sounds like what I describe above, but the problem with using that for things like = is that you can't write if a = b [...] but you have to say if (a = b) [...], because the only alternate rule for explaining "where to stop" is "go as far as you can" which winds up defined as "can you complete an expression" which runs into this "are you the last argument" deviation.
 
@HostileFork I think that that is hitting the nub of the problem now.
 
So my suggestion was that = and + and * are taken out of the bag of things that are like this. And |> and <| stay in the bag of things like that, but you just sort of live with the fact that they have to be wrapped in parentheses if you need to pass them as arguments, or be a branch in an IF or CASE or whatever.
 
We are trying to conceive a right half-breed of a semantics here, mixing infix with "normal" function calls. Things are bound to get rough ...
 
And I think there's value in being able to say there's just one kind of FUNCTION! and if we don't come up with any more parameter passing conventions than the current: normal, soft-quote, hard-quote (where soft-quote is purely an optimization, implementable through hard-quote at a mechanical level)
"One kind of function, two kinds of parameters"... if you will.
 
I am still at the point of refusing to accept not having any reduction capability. That is just too restricting.
I will put up with a lot of pain before I sacrifice that, though I do believe in what lies behind the idea of "just one kind of function".
 
1:31 AM
There's plenty of capability if you want a dialect. We can make fast variadic summers. (+ a b c d e f) could have just one frame level and do all the addition in native code.
 
again ... not math ... and I am talking about users, not me ... come on, man!
 
And why not a stack dialect? stacked [1 2 :add 3 :subtract]
 
specialized dialect to enable reduction ... what is wrong with you :)
 
I'm talking about users too, the cool new features that doing this right empowers. The thing is if you're going to go to bat for something awesome, you have to show some of those awesome things. I think <| and |> are great. I am wholly non-impressed by 1 + 2 * 3 = 9 vs. 7, so you really are going to have to come up with something more compelling.
 
If abandoning reduction seems OK to you, that sounds difficult.
 
1:35 AM
"reduction" as you are calling it is not abandoned, I showed you. It's actually the default for infix, that you have to override.
When you override it, you are making use of quoting the left hand side, which precludes the idea of evaluating expressions on the left hand side, since you want the immediate item before the operation.
 
@HostileFork Sigh. (1 + (2 + (3 + (4 + 5)))) is shifting, and uses stack. ((((1 + 2) + 3) + 4) + 5) is reducing, and doesn't.
Your idea implements the former, and prevents the latter.
 
@HostileFork I did that already. You are interpreting 1 + 2 * 3 as (3 * (2 + 1)).
The stacky way.
 
@MarkI No. It evaluates 1 + 2, with no multiplication on the stack. Then it multiplies it by 3.
 
Wait. What? Give me a sec.
 
1:41 AM
By default, an infix operator is seen as a "hold up" point. It will just hold up there and not process it, letting all in-progress evaluations go ahead first.
This is when its left argument is marked as not being quoted.
If it finds that it's being passed as an argument to a function, it will complain with an error.
But, if all is clean to the left (hits an expression barrier, start of group or block, etc) then it does as you would expect.
My explanation for the necessity of this error is that discomfort with the opportunistic "but where would you stop otherwise" aspect of the rule.
The ugliness above of writing if (a = b) [...] is why a quoted approach, opportunistic to the left, is suggested for such "ops"
 
But you said "The people who will not be happy will be the people who want 1 + 2 * 3 to be 9."
I am confused.
 
@MarkI Yes, because we don't want to do + and * and = this way, because we don't want to have to parenthesize them every time we pass them as arguments. But you claimed to not just want this for arithmetic and comparison, but this other purpose.
I'm saying as long as your "other purpose" doesn't mind the issue about parentheses to show "where to stop" as you called it, then it works fine with this rule.
 
@HostileFork Uber-confused.
Are we passing functions as arguments now?
 
@MarkI The only thing that changed from that greedy method we had studied before is that there isn't the "last argument" rule.
Now it just errors if you ever try to use ordinary "enfixed" things as an argument to a function, you must always wrap in parentheses if you are going to do that.
 
Oh, you're talking about add 1 2 * 3 being 9.
 
1:48 AM
Yes, this kills that.
 
A death you can put up with?
 
The idea being that enfixed operations which do not quote their left hand argument do work in this "reducing" (if you wish) way.
And pursuant to your "I'm not talking about arithmetic..." claim, I believe you could say I agree with you, because I wanted to get this behavior right for things like |> and <| which had a nice demo above.
4 hours ago, by HostileFork
>> summer: func [x [integer! <...>]] [
    sum: 0
    while [not tail? x] [sum: sum + take x]
    sum
]

>> sum: summer 1 2 3 |> 100 print ["sum was" sum]
sum was 6
== 100
However, we also need to talk about arithmetic and comparison, and the fact that people might get grumpy writing if (a = b) [...] instead of just if a = b [...].
 
I do not have much time remaining, and I do need to do some re-reading just to be sure, so, another time perhaps. Good chatting!
 
Ok. Well, we may be on the same page being the point.
 
Awesome if true :)
 
1:52 AM
You just have to accept that the comparison and arithmetic operators use a different "mode" of infix, where that mode arises from quoting their left argument.
But other "interesting" infix operations would not do this.
And if you don't mind parenthesizing to show "the leftmost place for the eye to scan", that's what it is asking for.
But you can do this with start of block as well, or expression barrier.
e.g. all [blah op blah op blah | print "hi"] can substitute for the forced parenthesization of if (blah op blah op blah) [print "hi"], if op is a "reducing" operation that is subject to this "can't be used raw as an argument" restriction.
 
@HostileFork I followed a bazillion steps and still confused on this! I'll keep reading
 
2:14 AM
@MarkI Easiest way to think of it: if an infix operation does not quote its left argument, it is "reducing", because its left argument must be evaluated before it can be put on the stack. If an infix operation does quote its left argument, it can't force evaluation of its left hand side before it executes... because the left hand side requires it to process that quoted argument and isn't allowed to process the quoted argument otherwise.
 
2:29 AM
add 1 2 op-left-arg-normal 4 => will run add(1,2) => 3, then op-left-arg-normal(3, 4)
add 1 2 op-left-arg-quoted 4 => will leave add suspended on the stack, run op-left-arg-quoted(2,4) => result, then resume add(1, result)
 
 
4 hours later…
6:07 AM
add 1 2 op-left-arg-normal 4 op-left-arg-normal 5 => add(1,2) to get 3, oplan(3,4) to get o34, then oplan(o34,5) is the final result.
add 1 2 op-left-arg-quoted 4 op-left-arg-normal 5 => push add(1,_), oplaq(2,4) to get o24, pop to get 1+o24, then oplan(1+o24,5) is the final result.
add 1 2 op-left-arg-normal 4 op-left-arg-quoted 5 => add(1,2) to get 3, push oplan(3,_), oplaq(4,5) to get o45, then pop oplan(3,o45) is the final result.
add 1 2 op-left-arg-quoted 4 op-left-arg-quoted 5 => push add(1,_), oplaq(2,4) to get o24, oplaq(o24,5) to get o245, then pop add(1,o245) is the final result.
@HostileFork ^-- as long as those are all true statements, I have no complaints.
 
@MarkI Yes, those are true. The caveat is that because of the "I don't know when to stop" nature of the left consumption, that you can't say print add 1 2 op-left-arg-normal 4 op-left-arg-normal 5 to print it out. You have to say print (add 1 2 op-left-arg-normal 4 op-left-arg-normal 5) or other mitigation.
Otherwise you get (print add 1 2) op-left-arg-normal 4 op-left-arg-normal 5.
 
Right, but that's only for the "normal" case, right? :)
 
Yes.
 
In the quoted case, it does know where to stop. Er, obviously.
Unless I am still misunderstanding something, I am pretty darned happy with this.
Shall we discuss equality and comparison?
 
@MarkI Actually, I take it back, in that, the quoted case the left-arg-quotes are greedy, hence it is add 1 2 op-left-arg-quoted 4 op-left-arg-quoted 5 will not allow the op-left-arg-quoted to take the 4.
The 4, being quoted left, is not available to be consumed evaluatively from the first operation's right.
 
6:15 AM
@HostileFork Right, the first one pre-empts it.
@HostileFork What?
 
user6438653
@MarkI Holy, shiet.
 
Right hand side arguments of these operations, unless they quote, are evaluated normally.
The fact that they do something weird with their left doesn't matter when they start operating to the right.
 
@WATERYMEL0N I see you in the sandbox.
 
user6438653
Hehe.
 
From a user's perspective, the right hand side of an enfixed or non-enfixed operation evaluate the same way.
 
user6438653
6:17 AM
Bye, sorry for interupting.
 
@HostileFork That's the stackiness I was referring to previously, then?
 
Yes, the quoting causes stackiness, and it's basically by necessity of the definition of quoting.
A wave of evaluation going from the left must be held up for a moment, in order to let the quote and its consumer be processed.
 
@HostileFork And that wave compounds?
 
If you have more quotes, yes. Or an ordinary function call with no lookback. The only non-compounding operations are those which evaluate left. (or which have terminated due to fulfilling their arguments)
print mold x ;-- "compounds", if you want to say so.
 
Well, at least we have nailed down the bone of contention, chained left-quoted operations, which don't stack in Alpha, stack in Ren-C.
 
6:23 AM
There are no left-quoted operations in R3-Alpha, there is only "single-unit-evaluatives" or somesuch.
 
We have returned to 1 + 2 * 3 being 7 in Ren-C, it would appear.
 
Unless you wish to make + and * evaluate their left hand sides.
And if you want to ponder a better way to allow, in that universe, if a = b [...] to not need parentheses, I will listen.
 
I want + and * to reduce BOTH their sides if they can! Like all operators do in Alpha.
 
But the only way I came up with to do it has a property we're not sure if we like.
 
@HostileFork Yes, that is tough.
And stop teasing me! :)
This is like the third time I thought we'd come together on this, only to be left ... dangling ...
 
6:27 AM
Well, there may be a better rule. I just haven't thought of it.
 
No worries. The profound takes time, like, the longest time.
2
 
The thing is, quoting enfixed operators are genuinely useful, and I would like to be able to have x <= [blah blah] or whatever, that can also soft-quote the left and do (first [x y]) <= [blah blah]
So they're something that's good to have anyway.
How it was done before was hacky for DEFAULT and ELSE etc., I'm looking at improving it.
 
6:52 AM
@MarkI One thing I am not so much emphasizing, but which is important, is getting rid of the very idea in the evaluator that there is any such thing as "evaluating with no lookahead". e.g. there is no DO/NEXT/NO-LOOKAHEAD or EVAL/NOLOOK or anything of that sort. So long as the mechanism behind tightness is what it was in R3-Alpha, that switch is in there...even if it's not exposed externally, mucking things up.
I basically want to say that if you run the code behind DO/NEXT, you never disable lookahead.
(Hence no if statements reacting to the flag, no flag for it, etc.)
Since quoting left hand sides has to stack, if you want to keep researching on the fringes of what to do to make expressions using evaluative left hand sides more friendly as function arguments, then do so.
 
 
2 hours later…
9:23 AM
>> foo: enfix func ['soft normal] [probe soft probe normal]

>> x foo 1 + 2
x
3
== 3

>> (first [x y]) foo 1 + 2
x
3
== 3

>> x: foo 1 + 2
x:
3
^--promising that I made a very drastic evaluator change, and it not only runs, but does that.
 
 
1 hour later…
10:46 AM
More demos on how to integrate and extend #Excel with libRed: https://github.com/red/red/tree/master/tests/libRed https://t.co/y9p1drwu7P
 
 
2 hours later…
1:07 PM
Technically the appropriation of quoting for infix purposes is a hack. In an ideal world there would be an "op eval" which gives 3 to foo as its first argument in add 7 1 + 2 foo 3 + 4, as well as a "funcall eval" which gives 10, an "op quote" which gives [1 + 2], and a "funcall quote" which gives [add 7 1 + 2].
Notably missing is any idea that foo should only see the 2 ... :)
I guess that'd be at least two more kinds, because we want (2) to be able to be passed as both (2) and 2, right? :/
 
 
4 hours later…
4:48 PM
posted on January 19, 2017 by giuliolunati

pick make map! [1 1] 1 ../src/include/sys-array.h:335: VAL_ARRAY: assertion "ANY_ARRAY(v)" failed

 
 
2 hours later…
6:47 PM
@MarkI The thing that I keep wanting to balance, though, is this notion of the complexity management. Not only does having a lot of different conventions turn the evaluator into a twisty thing that's ever harder to optimize, it increases the concerns of any user with some kind of meta-concerns about an unknown item they receive.
And some things have the additional problem of "I don't see how to make it work"/"paradoxes".
For instance, imagine a backwards quoting operator. x quote-left => x. Now imagine you put two of those in a row. x quote-left quote-left. If you're doing only one unit of lookahead, you've already executed the first quote-left, so the second quote-left can't run.
So that's an error case, and needs accounting for. Which isn't that hard to do. But the more of these things you mix in, the more you get.
And it's one reason why I've tried very hard to make this OneFunction work, where there's only one kind of FUNCTION!, and its interface is the same as the basic one people have come to know. Then push the lookbackness onto the word.
It will be disappointing if we can't do something about the parenthesization problem and the non-quoted, ordinary lookback. It would satisfy you and allow +: enfix :add and =: enfix :equal? to "just work". So keep thinking on it.
 
 
3 hours later…
9:50 PM
"insane" thought: what if x: + 10 added 10 to x. :-/
It could do that, as well as a + b, as well as (+ 10 20 30). But the add-to-quantity-in-a-set-word it can only do if it's a left-quoting operation.
(previous proposals use a different operation, x: ++ 10, given that x: += 10 is using = too C-like a meaning)
Could also be a generic thing. x: <- + 10, applying equally well to blk: <- append [something to append]
 
10:29 PM
@HostileFork can you check if the varargs things really works? See my last comment
 
@giuliolunati It works in my current build. Does [add 1 2] as the varargs work in yours?
Weirdness with infix that came up during messing with the varargs is one of the reasons why I'm back to tackling it. It was at first evaluating [1 + 2], but the problem was that it saw 1 as a "last argument" under the previous experimental policy and left the + 2 dangling for whatever came after the varargs, but in the MAKE VARARGS! case there is no "after the varargs" situation where the + 2 is seen.
 
@HostileFork yes, got 3
 
@giuliolunati I'm not sure why 1 + 2 is not giving you 3. If I remember right, this is supposed to be the patch that worked around it while I worked on the better solution.
@giuliolunati I stashed, built, and the example works in my copy of the current master also.
 
10:44 PM
However if x is hard-quoted the result is 3 again, not 'add
 
@giuliolunati I am getting that, and can look at it. But I am also getting 3 with 1 + 2.
 
Nada... :-( Tried also under linux -- complete re-build, always getting 1 with 1 + 2.
 
@giuliolunati Ok, it may only appear to "work" on my system due to a bug. :-/ Looking at it now.
I think, actually, we might want to abandon the way this is working in favor of the TAKE/EVAL vs TAKE. What this is trying to do is mutate the varargs when they are passed to take on the nature of their new parameter, and that's sketchy.
Although, I don't know. The idea is that it fills vararg slots with the frame's own information and then takes on the "data feed". This could be done in a different way than how I'm doing it.
 
I'm grateful to you for so much effort!
 
@giuliolunati Glad you're still using and experimenting! Someone needs to use these variadics and infix quoters and such :-)
And you are probably right... that a quoted variadic should be able to evaluate -or- quote, and you shouldn't need two feeds for that.
 
11:01 PM
@HostileFork I feel variadics have so much potential for dialecting.
 
But I do like the distinction that an evaluation-only variadic is like C, where you must know how many things to take by the data you have already committed to taking.
@giuliolunati When evaluative and quoted enfix is available, plus variadic, they make very cool things.
I don't know of any other language trying this particular twist.
@giuliolunati Do you feel it is a good idea to not have variadic data be typed, only the parameter? This is to say that you can pass an evaluated [integer <...>] variadic to a quoted [word! <...>] variadic, and it will not complain. I had initially intended that it would be typed, and you could only subclass it, and never pass quoted to unquoted or vice versa.
We are saying here that MAKE VARARGS! (at least for now) is "untyped" and can be passed to any variadic.
By the argument above about TAKE and TAKE/EVAL, it suggests that you could at minimum pass a quoted variadic to a normal one of matching type.
 
11:52 PM
@HostileFork I like this kind of flexibility... more flavour of natural language.
 
In flattening out Rebol, I am wondering if FUNCTION! is really just a "frame maker". So its raw low-level form would look like f: make function! [arg-quoted: take frame-of arg1 | arg-normal: take/eval frame-of arg1 | arg-quoted + arg-normal]
2
 

« first day (2272 days earlier)      last day (1508 days later) »