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

World: r3wp

[!REBOL3-OLD1]

BrianH
7-Feb-2009
[10754x2]
The one compare is dwarfed by the copy overhead though. Shifting 
the index only has significant overhead for ports, not series.
The list! type is gone from R3, and that was the only type with index 
overhead.
sqlab
7-Feb-2009
[10756]
dirize: func [file [file! url!] /off /local l][
	l: last file
	either l = #"/" [
		all [off remove back tail file]
	][
		any [off append file %/]
	]
	file
]
that should be a little bit faster
Chris
7-Feb-2009
[10757x4]
; Might also be faster than mine:

dirize: func [file [file! url!] /off][
	file: back tail file
	all [
		file = %/ = off
		either off [remove file][append file %/]
	]
	head file
]
(again, no copy)
Hmm, maybe not.
The pitfalls of none vs. false.
sqlab
7-Feb-2009
[10761]
dirize: func [file [file! url!] /off ][
	file: copy file
	either #"/" = last file [
		all [off remove back tail file]
	][
		any [off append file %/]
	]
	file
]
[unknown: 5]
7-Feb-2009
[10762x4]
dirize: func [file [url! file!] /off][

    head remove back tail make file either off [file][compose [(file) 
    "/"]]
]
dirize: func [file [url! file!] /off][

    to type? file head remove back tail make file! either off [file][compose 
    [(file) "/"]]
]
still a bit buggy but throwing it out there to play with.
dirize: func [file [url! file!] /off][

    to type? file head remove back tail make file! either all [off #"/" 
    = last file][file][compose [(file) "/"]]
]
Anton
8-Feb-2009
[10766]
Eh.. I prefer BrianH's separate UNDIRIZE (or FILEILZE) function than 
this /OFF refinement.
Henrik
8-Feb-2009
[10767]
I agree with Anton. IMHO, one should not build refinements that invert 
the behavior of a function. Refinements should extend a function's 
existing behavior, similar to what COPY vs. COPY/DEEP does.
Janko
8-Feb-2009
[10768]
in that light ...  does this solve >>exists? ; exists?/dir ; exists?/file 
exists?/...<< does this solve that problem too? >>- Using both DIR? 
and EXISTS? means two QUERY calls, which has overhead, particularly 
for networked files.<<
Henrik
8-Feb-2009
[10769]
that's where I would use separate functions for each operation. no 
need for multiple queries or curious refinements.
Janko
8-Feb-2009
[10770x2]
maybe I understood Brian wrong.. I thought in current situatuion 
you need to call exists? somepath and dir? somepath to know that 
something exists and is a directory (which also means two query calls 
I suppose)
will R3 have a way to define custom infix words?
Anton
8-Feb-2009
[10772]
Janko, yes, the current situation is exactly that; to know that a 
directory exists, you need to call exists? and dir?, which causes 
two QUERY calls.
Chris
8-Feb-2009
[10773x4]
Re: /off - it's not that different from 'trace or 'new-line.  It 
switches a mode, albeit using a refinement instead of a value.
Dirized is a state that 'dirize alters.
In R2, there are only two 'un verbs: 'unset and 'unprotect.  'undirize 
seems contrived (yep, dirize is contrived too, but necessary for 
a state that has no other name).
R2 Core, that is...
Anton
8-Feb-2009
[10777]
Fair point about new-line. But does 'undirize seem more contrived 
than 'dirize/off ? The prior seems more like English to me, the second 
is more "implementationish". I understand the desire to prevent another 
word in the global namespace, but I don't think 'undirize is going 
to collide with anything a user is likely to want to use .. !
Chris
8-Feb-2009
[10778x2]
Could also be that 'dirize has a permanent second logic! arg. It's 
not so much about namespace as language space.
dirize file on dirize file off
[unknown: 5]
8-Feb-2009
[10780]
This is a particular case.  I can see the useful ness from a mezzanine 
standpoint of having a function that does both add the "/" and subtracts 
the "/".  Because in the case of looping we can easily homegrow our 
own need there that would be more efficient.  But I agree the name 
of dirize is not so elegant.
Gregg
8-Feb-2009
[10781x2]
There's a big difference between an inverting refinment and a logic! 
parameter: default behavior. 


I'm all for a better name. Even better than that, a convention. Adding 
"ize" (dirize) or "ify" (blockify) isn't a great solution, but there 
is some basis for them (compartmentalize, normalize, scarify, terrify). 


TO-* and AS-* have specific meanings, and are core funcs. What should 
the standard derivation be for this kind of behavior?
Including antonyms (for lack of a better term).
BrianH
8-Feb-2009
[10783x4]
Janko: "will R3 have a way to define custom infix words?" To my knowledge, 
no.
As for the two query calls, look at the revised EXISTS? functions 
I posted above.
My original name for undirize was fileize, but that seemed even more 
contrived. The only advantage "undirize" has is that if you know 
what dirize does, it's not difficult to figure out what undirize 
does. The dirize function is only still called that for historical 
reasons, but we are trying to not just change the names of functions 
that act the same as R2 unless there is a really good reason for 
it. We prefer to only break compatibility for semantic reasons, not 
naming.
That said, I would like to have the BIND? function also assigned 
to the word BOUND? by default, or perhaps BINDING? or CONTEXT? given 
its behavior. Just a preference.
Pavel
9-Feb-2009
[10787]
What is R3 replacement for List! is it Map! or Vector! ?
BrianH
9-Feb-2009
[10788x5]
Neither - it's just gone.
The block-like types that aren't block-like enough to be bound are 
gone. Map! is not block-like, it acts more like object.
Vector! is more like a typed array. There is nothing in R3 like list! 
or hash!.
It was found that they were not useful or even used enough to be 
included.
Most uses of hash! are replaced by map!, the rest by block!. The 
only use of list! that couldn't be done with block! was found to 
be so obscure that no code was found that used that technique.
Dockimbel
9-Feb-2009
[10793]
I found hash! a very useful datatype, I still don't get why it has 
to be removed. Map! looks less flexible because you have to conform 
to the key/value data model and it doesn't seem possible to navigate 
in a map! like in a hash!. Why can't we have both hash! and map! 
in R3?
Pavel
9-Feb-2009
[10794]
Maybe would help to add indexing to Map! ie reverse value -> key 
?
ManuM
9-Feb-2009
[10795]
Exists a way to change user-agent with R3-alpha? I try system/schemes/http/user-agent: 
"Mozilla/4.0" but I get ** Script error: cannot access user-agent 
in path system/schemes/http/user-agent:
sqlab
9-Feb-2009
[10796x2]
probably you have to modify do-request.
save %do-req.r mold do-request
edit in do.req.r the line 
User-Agent: "REBOL"
to whatever you desire, add the rebol [] header and do the file.
sorry 
save %do-req.r mold :do-request
Steeve
9-Feb-2009
[10798]
hum, or you can pass a header block to the write function as is:
>> write [ url!  [ User-Agent: "TOTO" ... ]  #{...data...}]

but it's bugy, you have to add yourself some missing header properties 
in the block to generate a valid request.

like Content-Type: "application/x-www-form-urlencoded; charset=utf-8"
[unknown: 5]
9-Feb-2009
[10799]
I liked list and hash and did use them a lot.  List was was buggy 
though.
Steeve
9-Feb-2009
[10800]
eh ? bug in list ?
[unknown: 5]
9-Feb-2009
[10801x3]
Yes, I reported it some time back.
http://www.rebol.net/cgi-bin/rambo.r?id=4314&
Because of list being buggy sort was modified so that it doesn't 
use list.