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

World: r3wp

[!REBOL3-OLD1]

Volker
11-Feb-2007
[1959]
You can also not write your own 'do. IMO itis ok that  some things 
 are only possible at native level. Its  not  lisp.

inc/dec/shift are essential enough for speed and commodity, these 
could be an exception. (Maybe  evenn '<< and '>> as  operators, and 
allowed  in parser?)
Ladislav
11-Feb-2007
[1960]
as opposed to that, I guess that these cannot save much time anyway
Volker
11-Feb-2007
[1961x4]
four interpreter-steps instead of one? in a tight  search-loop?  
 until[pair? ++ blk]
btw i prefer post-increment.
but thats a rebcode-case anyway.
i dont like  the repitition when incrementing, moving. the two 'count. 
But  i have no good syntax :(
Gabriele
11-Feb-2007
[1965]
Geomol: as ladislav said, that method is already there. rebol does 
not have "by reference", so if you want passing "by reference" you're 
going to change the language a lot.
Geomol
11-Feb-2007
[1966x2]
Yes, I see.
I understand, why Carl is concerned, if he should include ++/-- or 
not. I don't think, we have something similar today working on scalar 
data types. An action like NEGATE doesn't change the variable holding 
the scalar data type:

>> negate 4
== -4
>> a: 4
>> negate a
== -4
>> a
== 4

So I bet it'll be confusing, if ++/-- does change the variable.
Izkata
11-Feb-2007
[1968]
What would this be called, then?  (I remember it came up before - 
I mean, what's this kind of variable passing called, if not "by reference" 
?)

>> ++: func ['X][set X (1 + get X)]
>> foo: 5
== 5
>> ++ foo
== 6
>> foo
== 6
Ladislav
11-Feb-2007
[1969x2]
another variant demonstrating the advantages of "transparent" argument 
passing:

++: func [x] [set x 1 + get x]
foo: 5
++ 'foo ; == 6
foo ; == 6
++ pick [foo bar] 1 ; == 7
foo ; == 7
Izkata: you cannot call it "by reference", since you are actually 
passing the value you are manipulating - the word, not a reference 
to it
Maxim
11-Feb-2007
[1971]
ladislav, that in C is just what a reference is... you pass not the 
value, but the pointer which refers to it... in REBOL that is a word. 
 under the hood, in REBOL everything really is a pointer to a value, 
with an offset within a context, no?
Ladislav
11-Feb-2007
[1972x2]
ladislav, that in C is just what a reference is

 - that looks like an error to me - references are in C++ actually. 
 Pointers are passed "by value" in C
in REBOL everything really is a pointer to a value, with an offset 
within a context, no?

 - you can explore how REBOL values look using my hints in this world 
 and at REP
Maxim
11-Feb-2007
[1974x4]
lad: a reference to a number is a common usage term which means get 
the pointer to the memory area where the number is contained... not 
the value at that pointer.  in C series variables have to be pointers, 
but numbers aren't usually pointers.  thus the reference to that 
number is its pointer.
if you pass the reference, and chance the value at that adress and 
change it in place... all "references" to it will change.
so I think you are both talking the same language, but with different 
terminology.... based on your usage of C..  :-)
(or C++)
Ladislav
11-Feb-2007
[1978]
what you are saying is terminologically misleading. "Pass by value" 
has got a broadly accepted meaning as well as "pass by reference". 
If you pass a pointer in C, then you pass it "by value" according 
to the definition.
Maxim
11-Feb-2007
[1979x2]
hehe, but you are passing the "value by reference"  ;-)
hehe isn't programming fun?  :-D
PeterWood
11-Feb-2007
[1981]
Isn't the real difference between passing a pointer by value or by 
reference is that when you are explicitly passing a pointer it is 
by value and when you are implicitly passing a pointer then it is 
by reference.

(Well that is my understanding from the difference in Pascal).
Ladislav
11-Feb-2007
[1982]
that is correct
Maxim
11-Feb-2007
[1983]
but what about values which are not defined as pointers like an int.
Ladislav
11-Feb-2007
[1984x2]
so what, are you trying to convince me, that in REBOL ints are "passed 
by reference"?
(if you speak about the C/C++ family then it is easy - in C++ you 
can pass int by reference, in C you cannot)
Maxim
11-Feb-2007
[1986x2]
REBOL passes values unless the function requires a "pointer" to them. 
 (not really a pointer, but in use pretty much the same result).
so I guess in your terminology, only series can be "references" in 
rebol right?
PeterWood
11-Feb-2007
[1988]
Surely one of the distinctions of pass by value and pass by reference 
is that in pass by value you work on a copy of the value not the 
value originally refered to:

>> a: 1                          
== 1
>> b: func [a [integer!]][ a: 2]
>> print b a                     
2
>> a: 1                         
== 1
Maxim
11-Feb-2007
[1989]
yes.
Ladislav
11-Feb-2007
[1990]
series can be references
 - actually not
Maxim
11-Feb-2007
[1991x2]
so in your terms, how could a reference be "simulated" in rebol?
or can they?
Ladislav
11-Feb-2007
[1993x2]
why not?, but it does not influence the fact, that when you are passing 
a word to a function, then you are "passing it by value", not by 
reference, I can easily show you a proof
(almost the same Peter wrote above)
Maxim
11-Feb-2007
[1995]
I think I just see the nuance in our statements... you're talking 
about the word supplied to the function I'm really talking about 
its value.  so yess I agree.
PeterWood
11-Feb-2007
[1996]
except my example was wrong
Anton
11-Feb-2007
[1997]
I'm with Ladislav on the C front, but it can be said that words are 
associated with their values, so they are pointers to them.
Ladislav
11-Feb-2007
[1998]
yes, that is OK
Maxim
11-Feb-2007
[1999x2]
you never get the actual word submitted to the function, even in 
the lit-word arg passing, you still get a new word within the function. 
 but its pointing to the same value.
ah.. what a little scribble on a piece of paper would do in these 
instances  ;-)
Ladislav
11-Feb-2007
[2001x2]
...that is the "pass by value" business
one exception regarding "pointer business" in REBOL: only words bound 
to a context can "point" to values
Maxim
11-Feb-2007
[2003]
yes... the act of binding creates the association (to use Anton's 
term :-)
Ladislav
11-Feb-2007
[2004]
question: do you think that the binding "act" changes the word in 
question?
Maxim
11-Feb-2007
[2005x2]
well, my research (of making a single block with 3 word of the same 
spelling with 3 different contexts and values) lets me to think that 
it only really sets the word with 2 values.  1) its context 2) its 
offset within that context (thus the data it should manipulate). 
 otherwise, it stays in place...
I did not do a lot of tests with aliases, cause I never found them 
of "obvious" use  (man I like that word, since terry used it so often 
 ;-)
Ladislav
11-Feb-2007
[2007x2]
I guess everybody would agree with you regarding the "obious" use
obvious
, sorry