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

World: r3wp

[Core] Discuss core issues

Pekr
23-Nov-2005
[2817x4]
how can I get some deeper context words? :-) I just wanted to check, 
if request-date finally uses system structure month/day names, so 
I sourced it:

request-date: func ["Requests a date." /offset xy][
    result: none
    if none? base [init]
    either offset [inform/offset date-lay xy] [inform date-lay]
    result
]
then I tried to add following:

insert at second :request-date 11 [probe date-lay]
but it does not know date-lay, like the word I added this way would 
not be bound to the context of the function? But looking at source 
it seems correct :-)
IIRC I successfully used such aproach in the past :-)
DideC
23-Nov-2005
[2821x3]
About request-date, I had reworked it for the "first" View 1.3 project 
(2 years ago). It use locales and some other enhancements. Just test-it 
directly :
do http://www.rebol.org/cgi-bin/cgiwrap/rebol/download-a-script.r?script-name=request-date
.r
Or have a look to the req-funcs object (with anamonitor ).
Anton
24-Nov-2005
[2824x2]
Pekr, you can do it by binding your 'date-lay to the 'date-lay that 
is already in the function body.

 insert second :request-date bind [probe date-lay] pick pick second 
 :request-date 10 2

(Mmm... request-date is quite an ill-behaved function. It sets 5 
words in the global context.)
Above I have bound your whole block of code to the existing 'date-lay 
word.

It could be better (a more reliable way in other situations) to bind 
just the 'date-lay word in your new code
(ie. only the words which need binding):

 insert second :request-date compose [probe (bind 'date-lay pick pick 
 second :request-date 10 2)]
Graham
25-Nov-2005
[2826]
Should 'forskip not take a block ?  As it is, it only takes a word.
Henrik
25-Nov-2005
[2827]
same with forall. a tad annoying, me thinks
Graham
25-Nov-2005
[2828]
Rambo it ?
Geomol
26-Nov-2005
[2829]
If it took a block, how would you make a reference to where you are 
in the block?
Graham
27-Nov-2005
[2830]
if you wish to parse a literal which changes ... how would you do 
that?

parse phrase [  'literal ]

can't be done this way

parse phrase compose [ '(literal) ]
Tomc
27-Nov-2005
[2831]
have you tried  parse phrase to block! join "'" 'literal
eFishAnt
27-Nov-2005
[2832]
what would the source of 'sixth be? (something like   sixth: func 
[ serease ] [pick serease 6] ;but how to make it be an action value?
Anton
27-Nov-2005
[2833x2]
Actions are like natives. They are built in and you can't make them 
yourself.
What makes you want to do that, though ?
Volker
27-Nov-2005
[2835x2]
Grham: use subrule
changing: ['literal]
parse phrase [changing]
Or do you want to catch any lit-word?
eFishAnt
27-Nov-2005
[2837x2]
Anton...I was afraid that would be the answer...course, maybe it 
works anyway...where a function! is used in the place of an action! 
(however, I dread there might be some side-effect if action! needs 
a context, and that context it needs is not provided by the function! 
substitute.
I will let you know if I reach a pitfall with my approach (so far, 
so good...;-)
Graham
27-Nov-2005
[2839x5]
Volker, the parse rule occurs in a BEER callback .. and I need to 
change the parse rule depending upon which BEER function I am calling. 
 Of course, there are always workrounds one can set up, but was wondering 
if there was some way to relax the REBOL interpreter when building 
up dynamic code like this.
I found myself writing lots of BEER code that all looked the same 
...
Seems the 'case statement is not in the encap from July last year 
and it's a native.
Anyone have source for a mezzanine case statement ?
Ahh... someone just posted one to rebol.org, but it doesn't work 
the same way as the native.
Ladislav's PIF function appears to be functionally similar to the 
new case construct

The old domain still seems to work

http://www.fm.vslib.cz/%7Eladislav/rebol/pif.r
Ryan
27-Nov-2005
[2844x2]
Great! A case statement! I have been waiting for that!
I like the functionality too. nice!
Ladislav
28-Nov-2005
[2846]
if you rename PIF to CASE (in the PIF source too), you hardly can 
find a difference
Henrik
28-Nov-2005
[2847x3]
is there a way to use a function with a refinement as a word?
something like:
do-a-function either condition ['ref][none] <arguments>

as opposed to the clumsier:


either condition [do-a-function/ref <arguments>][do-a-function <arguments>]
Volker
28-Nov-2005
[2850]
No good ways. You can build a path and do that.
JaimeVargas
28-Nov-2005
[2851x3]
Dialect
You can try multimethods.r
And have two singleton methods on the argument ref.
Volker
28-Nov-2005
[2854x2]
for own functions once i had an idea, but never really used:
f: func[/a va /b vb /opts blk][
 if opts[do bind blk 'opts] 
 ?? a ?? b
]
f/opts [a: 5]
Henrik
28-Nov-2005
[2856]
hmm... a bit confused about the BIND part...
Volker
28-Nov-2005
[2857x4]
it binds the opts-blk to the locals. then you can set the locals 
from the caller.
still confusing, but
ref-a: none
val-a: "A"
ref-b: true
val-b: "B"

f/opts [a: ref-a if ref-a[va: val-a]  b: ref-b if ref-b[vb: val-b]]
but then it needs a composeto avoid name-clashes. maybe not the best 
idea.
Henrik
28-Nov-2005
[2861]
you lost me :-) but it's ok, I'll try something with build-path...
Geomol
28-Nov-2005
[2862]
You can do this:

do to-path reduce ['do-a-function either condition ['ref][none]] 
<argument>
but if it's less clumpsy, you deside!
BrianH
29-Nov-2005
[2863x2]
; Try this way, no reduce or to-path...

do either condition ['do-a-function/ref] [:do-a-function] <argument>
; Or this
do pick [do-a-function/ref do-a-function] condition <argument>
Gabriele
29-Nov-2005
[2865x2]
Graham:
>> word: to lit-word! 'literal
== 'literal
>> parse [literal] [word]
== true