r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3-OLD1]

Ladislav
13-Feb-2007
[2054x2]
Maxim: "geomol and others...  INC with lit-words is seriously flawed 
in actual use ... a: inc a..." If I understood you well, you are 
saying, that you don't like an expression of the type: inc 'a, since 
the 'a looks unnatural to you. How about inc pick [foo bar] 1 then?
...or inc first [foo] ?
Maxim
13-Feb-2007
[2056]
what is:
inc pick [foo bar] 1

or rather, how often/when is this going to be used?
Oldes
13-Feb-2007
[2057x2]
I have nothing against lit-words. But maybe would like more inc a 
to increment a and change the value of a as well.
what would be faster:
inc some/object/some/value
or
some/object/some/value: inc some/object/some/value
?
Ladislav
13-Feb-2007
[2059]
inc (evaluate_something) : if you cannot use it, then the language's 
orthogonality is "impaired" (the language is referentially nontransparent, 
there are places, where you cannot put/evaluate an an expression
Maxim
13-Feb-2007
[2060]
in this case:

inc pick [foo bar] 1


there is nothing stopping inc from changing foo or bar also just 
like you?
Ladislav
13-Feb-2007
[2061]
do not understand your question...
Maxim
13-Feb-2007
[2062x2]
I just ask why  inc A  would behave differently than inc 'A
obviously, if A contains something else than a scalar, an error is 
raised.
Ladislav
13-Feb-2007
[2064x3]
because it is exactly the same case as in:

a: 1
equal? a 1 ; == true


, where we don't want to compare the variable with one, but the result 
of the expression (a), which is one
if we had: equal?*: func ['value1 'value2] [equal? :value1 :value2], 
then such a function would be totally useless
...since 
>> equal?* a 1
== false
Maxim
13-Feb-2007
[2067]
yes... but equal is a function... not an op ;-)
Ladislav
13-Feb-2007
[2068x3]
what? equal? is a prefix version of the = op
to be understood: I am not against side effects (changing the value 
of a variable), I am against nontransparency "impairing" the language
Maxim: I guess, that your anti lit-word contribution does not take 
this into account, does it?

    type? 'a ; == word!
Maxim
13-Feb-2007
[2071]
well type? evaluates 'a right?  which really is a word... Am I right?
Oldes
13-Feb-2007
[2072x2]
I'm not agains lit-word . But if I understand Maxim, he is scared, 
that in most cases we would use  inc 'a   because that's what at 
least the way I would used it - to change value of a
and to be correct, I would need to for example to change it in object: 
   inc some/object/a
Maxim
13-Feb-2007
[2074]
and inc 'a complicates other things ...
Oldes
13-Feb-2007
[2075]
I really don't like, that now I have to write  some/object/a: some/object/a 
+ 1
Maxim
13-Feb-2007
[2076x2]
exactly what Oldes just illustrates
but I understand what Ladislav means by inc 'a  in evaluating 'a 
 means increment the word which 'a points to.
Henrik
13-Feb-2007
[2078]
remove the inc 'a thing. Why would we need to check for lit words? 
it complicates things.
Oldes
13-Feb-2007
[2079]
Yes, I understand it as well. So I was asking if we can than have 
 inc some/object/'a  (which I found quite cryptic)
Maxim
13-Feb-2007
[2080]
whereas  inc a  means increment the content which is stored in a. 
 which could be a word, in which case, it will change the content 
of that word directly.
Ladislav
13-Feb-2007
[2081x2]
Maxim: "...I understand what Ladislav means by inc 'a  in evaluating 
'a  means increment the word which 'a points to" - actually not, 
I see it differently. INC 'a means, that before the INC obtains the 
argument value, an expression is evaluated and its value supplied 
as an argument. *if* you disallow that, then you disallow expression 
evaluation
and the funny thing is, that the lit-arguments don't disallow evaluation 
of all expressions, since the expressions of the :a type are evaluated!
Oldes
13-Feb-2007
[2083x2]
I give up... I'm lost in theory :-)
just give me something better than:  some/object/some/value: some/object/some/value 
+ 1
Ladislav
13-Feb-2007
[2085x2]
lost in theory? It is simple. INC is supposed to be a function. It 
either allows evaluation expression using normal argument, or it 
disallows expression evaluation using lit-argument.
what I say is bad is to disallow expression evaluation, since REBOL 
is an expression - based language, as you may recall
Oldes
13-Feb-2007
[2087]
Ok, that I understand.
Ladislav
13-Feb-2007
[2088x2]
that still may mean you may be able to write: inc 'a/b
(but don't forget about complications, when A is a function!)
Geomol
13-Feb-2007
[2090]
There might be options to solve the path situation:
inc some/object/some/'value
inc some/object/some/('value)
or maybe
inc '(some/object/some/value)
Just suggestions.

If you think, "inc a" should change a, then think about these, that 
we have today:
negate a
- a ; unary minus
abs a

Also many math functions, like:
exp a
log-e a
etc.

Why don't all those change a?
Ladislav
13-Feb-2007
[2091]
I guess it is a rhetorical question, but allow me to answer: because 
we need NEGATE, EXP, etc. to be able to process a result of a REBOL 
expression
Geomol
13-Feb-2007
[2092]
:-)
Ladislav
13-Feb-2007
[2093]
like exp (a + b)
BrianH
13-Feb-2007
[2094x5]
Oldes, how about:
    inc 'some/object/some/value
or:
    increment 'some/object/some/value 5

The second version of my functions without the lit-word formal parameters 
will do just fine.
I already solved the path situation. Read the code.
The relevant portion is:
    if path? :x [
        x: in do copy/part :x back tail :x last :x
    ]

This retrieves the word to be updated and puts it into the x local 
variable, just as if you had called the function like this:
    increment in some/object/some 'value 5
Ladislav, your point about SECURE using lit-word formal parameters 
is a good one. It is interesting to note that the parameter in question 
is a keyword, and that its binding or any references are ignored. 
Clearly lit-word formal parameters are useful for keyword arguments.
While we're at it Ladislav, I'd like your opinion about an idea I 
posted on the blog comments. I was thinking about the possibility 
of adding trampoline actions to the word! and path! datatypes.


When an action is called, execution is forwarded to a native function 
associated with the data type of the first argument, the action handler. 
In other languages this is called dynamic dispatch. My idea is to 
add action handlers to the word! and path! datatypes that would lookup 
any referenced value and forward execution to that value, and then 
possibly change the reference of the word to the result before returning.


This proposal would, in effect, add seamless support for side effects 
to REBOL evaluation. For instance, if there was a trampoline for 
the ADD action, increment would be basically this:
    add 'a 5


The disadvantage is that side effects won't be as clearly limited 
to set-word expressions and SET functions, so you would have to trace 
the dataflow to know whether the a in:
    add a 5

refers to a number, or to a word that refers to a number. There are 
other places in REBOL that need similar dataflow analysis to understand 
your code though - the consequence of dynamic typing.

What do you think?
Maxim
13-Feb-2007
[2099x2]
why not allow accessors for any types?
(and actually per instance, for some types)
BrianH
13-Feb-2007
[2101x3]
Well, because only series, any-word and object types have internal 
state that could be changed.
Number and character types are not modifiable. When you change a 
number, you actually replace it with a new number.
All of the modifiable types already have accessors, they're just 
awkward in some cases.