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

World: r3wp

[Core] Discuss core issues

BrianH
5-Jan-2010
[15363x2]
If you are interested in the GUI, get involved. We *really need* 
non-gurus - the GUI is designed for them.
If non-gurus can't use the GUI, it's a design flaw that needs to 
be fixed.
Graham
5-Jan-2010
[15365x2]
we non gurus need to wait for the gui .. or is it out now??
and this is in the wrong group ...
BrianH
5-Jan-2010
[15367]
Reichart hasn't yet restored the right group.
Graham
5-Jan-2010
[15368]
Ok, let's create a new r3 group ...
BrianH
5-Jan-2010
[15369]
No, let's not.
Graham
5-Jan-2010
[15370]
Can't wait forever ...
BrianH
5-Jan-2010
[15371]
I'm not waiting.
Graham
5-Jan-2010
[15372x2]
anyone got a code color rinser for R source?
http://www.rebol.org/view-script.r?script=color-code.r
Rebolek
6-Jan-2010
[15374x3]
>> a: [1 2]                 
== [1 2]


>> reduce [a swap a next a]

== [[2 1] [2 1]]

Why it doesn't return [[1 2] [2 1]] ?
This works as I expected:
>> a: [1 2] 
== [1 2]
>> compose/deep [[(a)] [(swap a next a)]]

== [[1 2] [2 1]]
Hm, I understand that now:

>> a: [1]

== [1]


>> reduce [a append a [1]]
== [[1 1] [1 1]]

Interesting. I never knew that.
Janko
8-Jan-2010
[15377]
it would be very helpfull if rebol could let you define functs that 
would warn you if you used or defined any global words .. 


I suppose my programs are 100% more uncertain because I forget to 
include some of the words I defined in words as local. If some 'funcstrict' 
for example would warn me of any such mistake I would sleep much 
better. Other but worse option is that there would be some lint like 
tool that would look at code and warn you of these
Dockimbel
8-Jan-2010
[15378x3]
AFAIK, static code analysis cannot be used on REBOL source code to 
infer the runtime behaviour accurately , word! values can be constructed 
and dynamically bound at runtime. Same reason why REBOL is not compilable.
Regarding capturing of globally defined words in a local context, 
as Gabriele likes to say : "for every code you would write that would 
work for you, I can write an example code that will break it" ;-)
Btw, R3 modules would minimize this issue to the local module only.
Janko
8-Jan-2010
[15381]
yes analysis could be hard or impossible if you look at more unusual 
things you can do.. but at least so that all. 


about second, maybe you mean the same.. but I just want that my certain 
functions set no global words, at least not directly with word: ~expr~ 
or set 'asd set [ asd asd ] ..
Henrik
8-Jan-2010
[15382]
setting no global words: use a context
Janko
8-Jan-2010
[15383x3]
I imagine when you now set some word in some function it looks at 
/local words and it it's there it creates a local word, if not it 
just sets a word (globaly).. let's say that there is funcstrinct 
that in second case just throws an error (probably something like 
that could be made in rebol itself)
Henrik: but I don't want to make each function a context (probably:) 
) .. I have to admit I don't know much about contexts .. only that 
it's like object
I am changing to using a context now for all words that are defined 
outside functions on rps pages to make them local to that pageload
Dockimbel
8-Jan-2010
[15386x2]
Just remembered about querying system/words, that would give you 
a mean to detect new global words.
>> query/clear system/words

== [end! unset! error! datatype! context! native! action! routine! 
op! function! object! struct
! library! port! any-type! any-word!...
>> context [set 'a 5]
>> query system/words
== [a]
Janko
8-Jan-2010
[15388]
cool! I was looking at system/words but had no idea how to see my 
words in there !  didn't even know for query word so far .. cool
Dockimbel
8-Jan-2010
[15389]
Detecting at runtime is the only way. So, you could write your funcstrict 
function using this 'query trick, but that would cost you 2 'query 
calls each time the function is called...
Henrik
8-Jan-2010
[15390]
janjo, you'll find that using contexts will help you solve these 
problems. it's the next best thing to modules.
Janko
8-Jan-2010
[15391]
Doc .. thanks a lot for that query word ... it' awesome to see on 
a page what all got set in the process.. this will help me the to 
make code more strong A LOT!


Doc.. how does the runtime binding to function local words work? 
func is probably not a  mezzaine or something where we could peek 
into what it does with /local words ?


Henrik: I need to learn more about them and how to use them .. are 
there any good docs to read about what contexts are used for maybe?
Henrik
8-Jan-2010
[15392]
Janko, try:

http://blog.revolucent.net/2009/07/deep-rebol-bindology.html
Dockimbel
8-Jan-2010
[15393]
Janko, a function is a context! value like objects. You can use the 
following mental analogy to see how it is related :

foo: func ["for demo" a [integer!] /local b][...]


would be *roughly* equivalent to constructing an object like that 
:

foo-def: make object! [
	hidden-ctx: make object! [a: none local: none b: none]
	body: [...]
	spec: ["for demo" a [integer!] /local b]
]


The body is bound to the 'hidden-ctx context at function creation. 
When calling 'foo, the interpreter will set the 'hidden-ctx object 
words values according to passed arguments and refinements and then 
DO 'body.


There's no differences on how REBOL treats "arguments" and "local 
words", it's part of the illusion. The /local refinement is used 
by *convention* only, to set "local words", you could just decide 
to use any other refinement for the same job. Here's an example :

>> a: func [/local b][print b]
>> a/local 5
5


Additionnaly, when you apply the ordinal natives on a function! value, 
you get :

>> first :foo
== [a /local b]		;=> the hidden context words

>> second :foo
== [...]			;=> the function body block

>> third :foo
== ["for demo" a [integer!] /local b]	;=> the original spec block
Henrik
8-Jan-2010
[15394]
trying:

source context

might be a revelation too.
Janko
8-Jan-2010
[15395x4]
huh.. plenty of info, might need some time to process this to get 
all that you two meant .


but I did already know first :foo second: foo stuff (I was playing 
with rebol to js compiler) and I did know that context is object
hm.. if rebol binds hidden ctx to function body then it really can't 
do anything to trigger warning on global words. (if I understand 
things aroung bind correctly)
ok .. query/clear will find me seek out leaking globals so this problem 
has got a solution in a way
if function uses objects and bind internally or something like that, 
then objects in rebol and bind should be cheap right? and then an 
object is cheaper than function ?
Dockimbel
8-Jan-2010
[15399x3]
if rebol binds hidden ctx to function body

 => It's the other way around, "binds body to ctx". BIND will only 
 link the words that match those defined in the target context, to 
 that same context, nothing more.
Object! and function! have different creation and usage semantics, 
AFAIU, they share a common internal parent datatype, context!. So, 
context! (which is not directly accessible) should be "cheaper". 
Objects and functions have different purposes, so this might be like 
comparing apples and oranges...in a closed blackbox.
BIND on a block! does a full recursive traversal of the block! and 
for each word! found, does a fast lookup in the target context (probably 
hashed). So the cost is directly proportional to the size and depth 
of the argument block!.
Terry
8-Jan-2010
[15402x4]
Is it just me, or does anyone else find JOIN and REJOIN cumbersome?
ie: Comparing to PHP

$var = "Hello World";

echo "This is $var in the sentence";
Rebol

var: "Hello World"
print rejoin ["This is " var "in the sentence"]
That's not too bad, but when you start including single quotes, double 
quotes, multiple variable etc, it becomes more difficult
Henrik
8-Jan-2010
[15406]
well, how else would you do it? I guess you need kind of an escape 
sequence to evaluate a word or something.
Steeve
8-Jan-2010
[15407x3]
there is plenty of functions to do such, the simple one is the one 
you can do
Terry, show use case you think is cumbersome and we'll show you a 
simpler way (i hope)
did you tried REWORD ?
Claude
8-Jan-2010
[15410]
terry:      var={coucou}            print rejoin [{hello + }  var 
{ à vous}]
Terry
8-Jan-2010
[15411x2]
$varA =<<<VA
 \'hello\'s {Worlds \';
VA;

$varB =<<<VB
 'and {so "on';
VB;
 
$n=<<<HD
<button onclick="alert('$varA ');">CLICK ME</button>
$varB
HD;

echo $n;
<<< is a here-doc in php