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

World: r3wp

[Core] Discuss core issues

JaimeVargas
14-Feb-2005
[431x5]
;Isn't this a bug?
>> parse #{000102} [#"^@" #"^A" #"^B"]
== false
>> parse #{000102} ["^@^A^B"]             
== true
>> parse #{000102} [#"^@" #"^A" #"^B"]
== false
>> parse #{000102} ["^@^A^B"]
== true
I think AltMe is escaping some characters... I hope you guys can 
copy it and see the actual problem.
;The problem doesn't seem to exist for printable chars.
>> parse #{313233} [#"1" #"2" #"3"]
== true
>> parse #{313233} ["123"]
== true
;Ah. Never mind I forgot about parse/all
>> parse/all #{000102} [#"^@" #"^A" #"^B"]
== true
Ladislav
16-Feb-2005
[436x2]
is there a way how to "simplify" this? (queue is a list!)

	if any [error? try [tail? queue] tail? queue] [

  queue: head queue ; start at a "meaningful" position in the queue
	]
(I would say it is an implementation quirk)
Dockimbel
16-Feb-2005
[438]
If queue is a list!, why would [tail? queue] fail ? Can 'queue refer 
to other kind of value than a list! value ?
Chris
16-Feb-2005
[439]
all [series? queue tail? queue queue: head queue]
Ladislav
16-Feb-2005
[440]
>> queue: make list! [1 2]
== make list! [1 2]
>> remove queue
== make list! [2]
>> tail? queue
** Script Error: Out of range or past end
** Near: tail? queue
Chris
16-Feb-2005
[441x4]
all [attempt [tail? queue] queue: head queue]
But looks like there are greater problems...
queue: remove queue -- would fix it too...
>> queue: make list! [1 2]
== make list! [1 2]
>> queue: remove queue
== make list! [2]
>> all [tail? queue queue: head queue]
== none
Ladislav
17-Feb-2005
[445]
the last one seems to be the best
Louis
22-Feb-2005
[446]
Is there a command to give the path to the presently used user.r 
file?
Anton
22-Feb-2005
[447]
One of these will probably help you:
>> system/options/path
== %/D/Anton/Dev/Rebol/View/
>> system/options/home
== %/D/Anton/Dev/Rebol/View/
>> system/options/boot
== %/D/Anton/Dev/Rebol/View/rebview1257031e.exe
Louis
22-Feb-2005
[448x3]
Thanks, Anton.  Rebol seems to be looking for user.r in system/options/home 
or system/options/path.  It would seem to be more practical for it 
to look in system/options/boot.
But I guess each directory might need a different user.r.
I trying to get set up to use your dir-utils.r.  Thanks for your 
good work on this.
Anton
22-Feb-2005
[451]
Louis, I think: 

system/options/path  is the current directory of the shell environment 
where rebol was started from.

system/options/home  is the rebol starting directory, where it looks 
for user.r etc. In WinXP this value is taken from the registry at 
HKCU\Software\Rebol\View\HOME, but only for full release versions 
(like Rebol/View 1.2.1.3.1). I imagine there is a HOME environment 
var set in *nix.
DideC
22-Feb-2005
[452]
REBOL_HOME afaik
Geomol
23-Feb-2005
[453]
Does REBOL miss a way to go up one level of blocks within blocks? 
Example:

>> blk: [[a b c] [d e f]]
== [[a b c] [d e f]]
>> p: first blk
== [a b c]


Now I would like to have p go up one level, so I can continue to 
the next block (the [d e f] block) within blk. Using blk to do it 
is not a solution, because we could have blocks within blocks within 
blocks ... to any level. What about a parent function like:

>> p: parent p
DideC
23-Feb-2005
[454]
It require bidirectinnal pointer:
- parent -> child (we have that : parent/child-index)
- child -> parent (we DON'T have that !)
You have to hold the reference yourself.
Volker
23-Feb-2005
[455]
you can put the same block in two others, which one is parent?
Sunanda
23-Feb-2005
[456]
Not really possible without an extra data structure.
Why not simply make the parent the 1st entry in the block?
>> blk: copy []
== []
>> append/only blk blk
== [[...]]
>> append blk "a"
== [[...] "a"]


(One drawback is that this sort of recursive structure cannoy easily 
be molded and later loaded_
>>
DideC
23-Feb-2005
[457]
Use a block and Push reference to the parent when you go into the 
child. Then Pop the reference when you want to go up one level.
Geomol
23-Feb-2005
[458]
Volker is right! Which one is the parent? Ergo we can't have a parent 
function. And then again, we have to use a trick, where we store 
the block at any level. (You other guys are right too, and I think 
the actual design is the best way, I just have to keep in mind, why 
it is like this.) :-)
Chris
23-Feb-2005
[459]
DideC, do you have an example?  I've seen the terms 'push and 'pop 
before, but have not seen a comprehensive example of it...
DideC
23-Feb-2005
[460]
There was a discussion about stack implementation the 27-jan in this 
group. Go up, there is the code from Robert and others
Chris
23-Feb-2005
[461]
Thanks, missed that...
Geomol
23-Feb-2005
[462x3]
I find this a bit strange and problematic:

>> blk: [/]
== [/]
>> type? blk/1
== word!
>> parse blk [/]
== false

How do I parse a slash within a block?
Answer: parse [/] [set w word!]

Sorry to bother you. ;-)
Well, I'm not 100% satisfied. Look at these:

>> parse [a] ['a]
== true
>> parse [/] ['/]
** Syntax Error: Invalid word-lit -- '
** Near: (line 1) parse [/] ['/]

Shouldn't '/ be a valid lit-word?
Pekr
23-Feb-2005
[465]
imo Rebol is so free form, that you imo can find lot of such inconsistencies 
here ...
Chris
23-Feb-2005
[466]
>> slash: to-lit-word "/"
== '/
>> parse [/] [slash]
== true
Geomol
23-Feb-2005
[467]
Thank you very much! :-)
Anton
23-Feb-2005
[468x2]
Careful, by default:
>> slash
== #"/"
It might be used in some other code.
Geomol
24-Feb-2005
[470]
Yes, I called mine lit-slash.
JaimeVargas
24-Feb-2005
[471]
;I find this amazing.


>> o: make object! [sub-o: make object! [name: 'sub-o f: func [v][2 
* v]]]
>> ? o    
O is an object of value: 
   sub-o           object!   [name f] 

>> var: in o 'sub-o
== sub-o

>> ? var  
VAR is a word of value: sub-o

>> value: get var
>> ? value
VALUE is an object of value: 
   name            word!     sub-o 
   f               function! [v] 


;What I find amazing is that you can get the content of the object 
SUB-O by doing GET VAR

;Some how the context where 'SUB-O is defined gets attached to VAR 
or SUB-O by IN O 'SUB-O


;just to check, the global context doesn't know anything about SUB-O
>> ? sub-o
No information on sub-o (word has no value)
>> sub-o
** Script Error: sub-o has no value
** Near: sub-o
Ammon
24-Feb-2005
[472x2]
It is because the VALUE not the word contains the CONTEXT information 
meaning that VAR (as you defined it) referenced the value SUB-O which 
happened to be a word with the context of O
...a word WITHIN the context of the object that the WORD O refers 
to...
JaimeVargas
24-Feb-2005
[474]
It surely allows for some very neat programing tricks ;-)
Ammon
24-Feb-2005
[475]
Yes, it does. ;-)
Anton
24-Feb-2005
[476x3]
Each word "knows" which context it lives in. When you make a new 
object, the top-level set-words are BINDed to it. So each word knows 
its binding.
I think Ladislav used to have a nice example where each of the words 
in this block could refer to different values, because they were 
bound to different contexts:   [word word word word]
They all look the same, but just looking at this you cannot tell 
which context each word is bound to.
BrianW
24-Feb-2005
[479]
sounds kinda cool but scary from a code maintenance perspective.
Anton
24-Feb-2005
[480]
Bah.. We use this feature all the time without thinking about it. 
Take a look at this: