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

World: r3wp

[Core] Discuss core issues

PeterWood
12-Feb-2007
[7163]
So you'd really like Rebol to have the equivalent of JavaScript's 
Delete operator?
Maxim
12-Feb-2007
[7164x2]
hum don't know about it... but if I could do 

obj: make/without ref-obj [] [select]

We could already shrink our objects, when its needed.
binding would then have to replace any object-local bindings of select 
to the global context and raise an error if it doesn't exist, as 
it would if you had tried to define a new object with select undefined 
in any place.
PeterWood
12-Feb-2007
[7166x2]
One think that I like in JavaScript is the flexibility to freely 
add and remove members from object instances and object prototypes 
.
think -> thing
Maxim
12-Feb-2007
[7168x2]
it is usefull only when it is something which is not automatic like 
in python, where its nightmarish.
if you inadvertently typo , then you create a new member!  talk about 
hard to debug errors!!
Joe
13-Feb-2007
[7170]
how does the path native work ? I couldn't find it in the rebol dictionary
BrianH
13-Feb-2007
[7171]
Joe, that native is an accidently exposed internal function. It has 
no use externally.
Henrik
14-Feb-2007
[7172]
If I'm calling a function with many different refinements and the 
function has to work recursively and all refinements must be maintained 
throughout recursion, is there an easy way to get the function call 
with all refinements?

I'm using:


>> f: func [/a /b] [to-path remove-each p reduce ['f all [a 'a] all 
[b 'b]] [none? p]]

>> f
== f
>> f/a
== f/a
>> f/b/a
== f/a/b ; lose refinement order
Anton
14-Feb-2007
[7173x4]
I'm not sure if this helps but I sometimes make a wrapper function 
which calls the actual recursive function. The wrapper could take 
the refinements and set some flags in a context shared by all calls 
to the inner recursion function.
Oh hang on, your question indicates that your example code above 
is currently working, but you are looking for a better way. Is that 
correct ?
A "how was this function called ?" function. I don't think there 
is a way. (although in recent discussion on BIND?....)
ooh.. actually....
Henrik
14-Feb-2007
[7177]
1. it currently works but is clumsy, I think
2. "how was this function called ?" = yes
Anton
14-Feb-2007
[7178]
How about this:
>> f: func [/a /b][print mold second bind? 'a]
>> f/a/b
[true true]
:)
Henrik
14-Feb-2007
[7179x2]
there is something about that you don't know the actual function 
name inside the function? if only the refinements and their order 
could be managed.
testing...
Anton
14-Feb-2007
[7181x2]
That's right, since several words can refer to the same function, 
it has no "one" word.
(it also could be an anonymous function)
Henrik
14-Feb-2007
[7183]
well, that only brings up a block and the refinement order is still 
off, which would be a problem if your refinements have arguments
Anton
14-Feb-2007
[7184x2]
I see.
I think you must pass in the code which is used to launch the function 
as a function argument :)
Henrik
14-Feb-2007
[7186]
nasty!
Anton
14-Feb-2007
[7187]
yep :)
Henrik
14-Feb-2007
[7188x2]
I wonder how hard this would be to implement in a single function. 
Probably very hard if functions internally are unaware of refinement 
order
very hard = impossible :-)
Anton
14-Feb-2007
[7190x3]
Well, given a function
f: func [code /a /b][print mold second bind? 'a]
do append/only copy code: [f/b] code
--->  [[f/b] none true]
Since I've passed in the code to call the function, it knows how 
it was called, and the order of refinements. The refinements are 
listed in spec order in the function context though.
What's the actual application for this recursive function, by the 
way ?
Henrik
14-Feb-2007
[7193]
it's a file packing function. refinements are used to determine which 
files should be skipped and which files should be processed with 
other external functions
Anton
14-Feb-2007
[7194]
And why does it need to be recursive ? Recursing directories ?
Henrik
14-Feb-2007
[7195x2]
I use it in many places for slightly different purposes
yes
Anton
14-Feb-2007
[7197]
ok, so more an abstract general idea.
Ladislav
14-Feb-2007
[7198x2]
I think you must pass in the code which is used to launch the function 
as a function argument :)
 no need, pass-args can handle everything
, but a native APPLY handling refinements transparently would definitely 
help
Gabriele
14-Feb-2007
[7200x4]
Henrik: why is the refinement order important to you? (since there's 
no way to know it from inside a function)
if you have control over the function, write a (recursive) function 
without refinements and a wrapper with refinements that calls it. 
(this is the best solution)
if you don't have control over the function, Ladislav's pass-args 
or similar techniques are the most general way to solve the problem. 
easier/faster solutions may be available in specific cases.
a native APPLY would solve all of this elegantly... hopefully we'll 
get one :)
CharlesS
15-Feb-2007
[7204]
aye, I look forward to apply too :)
Robert
19-Feb-2007
[7205]
What does PATH do?
Rebolek
19-Feb-2007
[7206]
in immortal words of Kurt Cobain "who knows? not me."
and this probably won't help very much:
>> ?? a
a: make object! [
    b: 1
]
>> path a 'b
>> ?? a
a: make object! [
    b: end
]
Oldes
19-Feb-2007
[7207]
this is thee end...this is thee end my friend... (but that's another 
song..)
PeterWood
19-Feb-2007
[7208]
So what does end do?
Rebolek
19-Feb-2007
[7209x2]
I don't know. let's continue with the example:
>> type? a/b
== unset!
well, that's my fault, sorry
Oldes
19-Feb-2007
[7211]
Don't know what PATH does...
>> x: first [a/b/c/d]
== a/b/c/d
>> y: path x 'b
** Script Error: y needs a value
** Near: y: path x 'b
>> ?? x
x: a/b
Rebolek
19-Feb-2007
[7212]
hm I'm now lost even in REBOL. back to that terrible Perl/OLE combination 
:/