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

World: r3wp

[Core] Discuss core issues

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 
:/
Robert
19-Feb-2007
[7213]
Can this routine (http://www.rebol.net/article/0281.html) for copying 
large files be used to transfer a file over a network as well?
Oldes
19-Feb-2007
[7214]
of course it can
Robert
19-Feb-2007
[7215x2]
Sounds good. What do I need to change? I'm really not a network expert 
nor a port expert.
because at the moment it only takes file! as argument. Does switching 
to url! is enough?
Oldes
19-Feb-2007
[7217x2]
but maybe not, I'm not sure how it's with the seek
just try to add url! into "from" argument and try it
Anton
19-Feb-2007
[7219]
It depends if the particular server supports resume. My batch-downloader 
manages to do resumes from most FTP sites I have tried.
Robert
19-Feb-2007
[7220x3]
Is it at rebol.org?
Does it support FTP login?
But FTP might have problems with corporate firewalls, right?
Anton
19-Feb-2007
[7223x3]
See
http://anton.wildit.net.au/rebol/util/batch-download.r
http://anton.wildit.net.au/rebol/util/demo-batch-download.r
It supports FTP urls. If the url can contain the login details, then 
it should be ok.
Sorry, my first comment above "resumes from most FTP sites" should 
be "HTTP sites". I've not widely tested it with FTP, only with a 
few FTP files Graham was using for his EMR project.
Robert
19-Feb-2007
[7226]
Ok, so it's for HTTP download? That's good! :-)
Oldes
19-Feb-2007
[7227]
What would be the best way how to delete for example last 100 lines 
from really large file?
Robert
19-Feb-2007
[7228]
PATH: Looks like a simplyfied find & copy combination to me.

>> ? path
USAGE:
    PATH value selector

DESCRIPTION:
     Path selection.
     PATH is an action value.

ARGUMENTS:
     value -- (Type: any)
     selector -- (Type: any)
>> a: [1 2 3 4 5]
== [1 2 3 4 5]
>> path a 3
>> a
== [1 2]
>> path a 3
>> a
== [1 2]
>> a
== [1 2]
>> head? a
== true
>> head a
== [1 2]
>> a
== [1 2]
>> tail a
== []
>> a
== [1 2]
>> a: [1 a 2 b 3 c 4 d 5 e]
== [1 a 2 b 3 c 4 d 5 e]
>> path a 'd
>> a
== [1 a 2 b 3 c 4 d]
>> a: [1 a 2 b 3 d c 4 d 5 e]
== [1 a 2 b 3 d c 4 d 5 e]
>> path a 'd
>> a
== [1 a 2 b 3 d]
>> a: [1 a 2 b 3 d c 4 d 5 e]
== [1 a 2 b 3 d c 4 d 5 e]
>> path a 't
** Script Error: Invalid path value: t
** Near: path a 't
>> a: [1 a 2 b 3 [d] c 4 d 5 e]
== [1 a 2 b 3 [d] c 4 d 5 e]
>> path a 'd
>> a
== [1 a 2 b 3 [d] c 4 d]
>> path a [d]
>> a
== [1 a 2 b 3 [d]]
>> a: [1 a 2 b 3 [d] c: 4 d 5 e]
== [1 a 2 b 3 [d] c: 4 d 5 e]
>> path a to-set-word 'c
>> a
== [1 a 2 b 3 [d] c:]
>>
Oldes
19-Feb-2007
[7229x3]
I don't thing it's correct behaviour:
>> a: [1 2 3 4 5]
== [1 2 3 4 5]
>> path a 3
>> a
== [1 2]
>> a/3
>> a/4
== 4
>> a/5
== 5
>> length? a
== 5
>> a
== [1 2]
>> type? a/3
== unset!
I think it just corrupts the block somehow
Izkata
19-Feb-2007
[7232]
Huh.  Looks like it's marking the end of the block without actually 
removing elements, so that they're still accessible if really needed.

>> A: [a b c d e]
== [a b c d e]
>> path A 3      
>> ? A
A is a block of value: [a b]
>> A/2
== b
>> A/3
>> A/4
== d
>> mold A        
== "[a b]"
>> back tail A
== [e]
>> back back tail A
== [d e]
>> back back back tail A
== []
>> back back back back tail A
== [b]


I can see myself using this...  And I think I'd actually had a problem 
a while back where it would have been helpful.
CharlesS
19-Feb-2007
[7233x4]
Im iterating over a lines in a file , with this line in a foreach 
body
if find tempLine "//Database " <> none [ print "Here" print line 
 ]
but the print line is printing [ true; ] instead of the actual line 
?
oh hmm, im splitting by lines with this -> lines: parse (read to-file 
rejoin [ moduleName ".php" ]) "^/" , but it seems to be splitting 
by spaces ?
Steeve
19-Feb-2007
[7237]
parse/all
CharlesS
19-Feb-2007
[7238x2]
that works, but the find function doesnt seem to be working, the 
two lines it returns for matching //Database are var $new_schema 
= true; and case 'ACL': return true; ---
those are the only two lines that have true in them