« first day (1453 days earlier)      last day (2327 days later) » 

3:59 AM
Reading recent discussions about the 'function, so far, I did not care much, untill the discussion happened in Altme. So far my conclusion is, that anything like 'function should be eradicated, as looking at following two examples reveals, how flawed the decision is
From Andreas on Altme:
foo: function [] [bar: function [] [a: 1] a = 0]
>> source foo
foo: make function! [[/local bar a] [bar: function [] [a: 1] a = 0]]
It is imo unacceptable, how 'a can end-up being local to 'foo and not 'bar. Both are 'functions, so should collect locals ...
We are either claiming, that code is data, and that functions are just blocks, but if so, then we should not really mess with it, and simplyfying it just by scanning whole structure for set-word, resulting in above "code", which is simply semantically incorrect. It is like defending the reason for a memory leak ...
Another such case is: foo: function [][o: object [a: 1]] ... Well, 'a gets leaked into 'foo. Now if you thought that we used contexts to isolate values, you are wrong again ...
 
4:28 AM
Well, at least there is /extern refinement, to get code as I expected. Gurus would claim, that it already worked, as expected
foo: function/extern [] [bar: function [] [a: 1] source bar] [a]
>> foo
bar: make function! [[
/local a
][a: 1]]
 
; Brought to you by: try.rebol.nl
; rebol.com/r3/docs/errors/script-no-value.html
    *** ERROR
** Script error: foo has no value
** Where:
** Near: try load/all join %/users/try-REBOL/data/ system/script/args...
 
 
13 hours later…
5:12 PM
@pekr the issue is that it's not a context or it's not a function until it is actually evaluated. What kind of behavior would you expect for it to evaluate, but not evaluate the body of the function? It's just following a simple rule that if it's a set-word! inside the function body, then it's counted by function as local
@pekr it's not local to bar until the block of the function is evaluated. It will be when it's evaluated
>> foo: function [] [bar: function [] [a: 1] a = 0 source bar]
>> foo
bar: make function! [[
    /local a
][a: 1]]
And whatever happens inside bar doesn't leak out to the rest of the foo "scope"
The only side effect of this seems to be having an extra (possibly unused) local variable in foo. I don't think this will cause the kind of danger that you are worried about.
 
5:38 PM
And this effect saves global leaking, such as in this case:
. >> foo: function [] [bar: function/extern [] [a: 1] [a] bar print a]
>> foo
1
>> a
** Script error: a has no value
 

« first day (1453 days earlier)      last day (2327 days later) »