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

World: r3wp

[Core] Discuss core issues

Henrik
16-Nov-2009
[15006x2]
well, that's actually better, because I can put several refinements 
on top of a path!, which is really what I want:

>> a: 'b/c
== b/c
>> join a 'e/d
== b/c/e/d

but that final bit about using refinements alone would be cool
ok, I didn't get the block connection there, but I see it now.
Geomol
16-Nov-2009
[15008x2]
It is a bit confusing, also because both path! and file! are series, 
so it's easy to think, they should work the same.

>> series? d
== true
>> series? %/a/b/c
== true
A question: can it be justified, that file! is a series?

>> a: %/c
== %/c
>> first a
== #"/"
>> a/1
== %/c/1


Is file! a pseudo-series? What exactly defines a series? It's some 
sort of a sequence of values, that can be picked individually. And 
series can be sorted, right? So the methods (or functions), that 
can be performed on the datatype defines its type. What defines a 
series in REBOL?
Maxim
16-Nov-2009
[15010x4]
hehe I was writting up the EXACT same reply than geomol pointing 
out block and how to use do join x y ... had to for an exam at the 
dentist... I come back and geomol beat me to it  ;-)
each series type handles path actions how it wants to.
files append to themselves, blocks do lookup, strings return chars.


to be a series, in has to support insert, copy, first  which is why 
tuple isn't a serie.
in = it
BrianH
16-Nov-2009
[15014x2]
Henrik, in R3 use get-paths instead:
>> a: reduce [func [] [print "hello"]] c: 1
>> a/:c
hello
>> print mold :a/:c
make function! [[][print "hello"]]


Get-paths solve your problem of delayed evaluation without using 
GET IN. Your example would be d: :a/:c insteac of 'a/:c.
Geomol: "What defines a series in REBOL?"


A series has contents, sequence and persistent position. The characters 
that make up a file (contents) are in a specific order (sequence) 
and you can do an offset reference to a later offset in the filename 
(position). If you do FIRST %a it will return #"a" every time (persistent 
position). Being a series doesn't mean that it is sortable, though 
many are. Being sortable means also having the contents be comparable, 
and the series be modifiable.


We were careful to make sure that things that aren't really series-like 
were removed from the series! typeset in R3. R2 is less consistent 
in this regard, so you have some types attempting to act series-like, 
poorly - pots being the worst example.


Some of the functions that act on series also act (differently) on 
non-series, but not all.
Maxim
16-Nov-2009
[15016]
pots?
BrianH
16-Nov-2009
[15017]
ports (stupid keyboard)
Maxim
16-Nov-2009
[15018]
I thought that to qualify to be a series, a type also needed to support 
insertion, not only indexing and content.


cause your above definition qualifies tuple! to be a series, but 
they aren't.
BrianH
16-Nov-2009
[15019x2]
Tuples don't have position.
Give me a sec, I'll list out the relevant functions...
Maxim
16-Nov-2009
[15021x2]
hehe, yeah.... doh!  ;-)
(above related to tuple position comment)
BrianH
16-Nov-2009
[15023]
Position: HEAD, TAIL, HEAD?, TAIL?, AT, SKIP, NEXT, BACK

Contents: PICK, POKE (for modifiable series), ordinals (FIRST, ..., 
LAST)

Sequence: PICK and POKE can use numbers (used to implement ordinals)

Persistent position and sequence: All of the above are repeatable, 
with no position change side effect.
Maxim
16-Nov-2009
[15024]
and INDEX?   ;-)
BrianH
16-Nov-2009
[15025x4]
Right, as a position function.
LENGTH? too. Note that in R3 an image! counts as a series, though 
it has 2 different position measures.
Bitsets, tuples, objects and maps don't have position. Objects and 
maps don't have sequence either (at least not in theory).
Ports in R3 (or open/direct or command ports in R2) don't have persistent 
position and sequence, or reference position. This makes them streams, 
not series.
Maxim
16-Nov-2009
[15029]
yes basically, they are always at position 0 and looking at the data, 
implies you remove it, so ports are like quantum series  ;-)
BrianH
16-Nov-2009
[15030]
The reference position vs inherent position distinction is important. 
That is why the position functions are seeking procedures for ports, 
while they are pure reference-returning functions for series.
Chris
16-Nov-2009
[15031x2]
It'd still be nice to have an interface that in some ways behaved 
like R2 ports (I think of it as adapter!) that allow the above series 
functions to operate on customised, abstracted series.  Perhaps I'm 
overlooking a simpler way of addressing the problems I have in mind.
It seems (by my reading) R3 ports have evolved toward more closely 
modelling streams of data as opposed to pools.
Henrik
17-Nov-2009
[15033]
BrianH, I don't understand your get-path example. How can I use it 
to build more paths? You have to remember that I'm not interested 
in having a default path which then is altered. I want to build then 
by joining several paths together, just like file! does.
BrianH
17-Nov-2009
[15034x2]
Well, paths are like blocks, not like filenames. You can't make them 
act like filenames without breaking them *in every other way*. You 
can build path just fine with JOIN and APPEND, you can fully evaluate 
them with DO, and you can partially evaluate them with get-paths 
without ever needing to use GET IN. Functionally, there is no problem 
with R3's current behavior except bugs 396, 861, 1236, 1339, and 
maybe 746 and 803.
We can safely assume that you are talking about R3 when proposing 
that behavior be changed, since R2 is in compatibility mode.
james_nak
18-Nov-2009
[15036]
Anyone know a simple way to transform a block of sub-blocks into 
a single block while retaining the original type? I have [ [1] [2] 
[3]] and I'd like [ 1 2 3]. I can do with with form and parse but 
it  then I get ["1" "2" "3"].
kcollins
18-Nov-2009
[15037]
result: copy [] foreach x [[1 2]] [3 4] [5 6]] [append result x]
Geomol
18-Nov-2009
[15038x4]
>> blk: [[1][2][3]]
>> forall blk [change blk blk/1]
>> blk
== [1 2 3]
My version can only copy with subblocks of length 1.
copy = cope
Maybe better:
forall blk [change/part blk blk/1 1]
Izkata
18-Nov-2009
[15042]
Slight differences - no internal blocks are preserved in Geomol's:
>> blk: [1 [2] [3 [4]] [5 6]]    
== [1 [2] [3 [4]] [5 6]]
>> forall blk [change/part blk blk/1 1]                     
== []
>> blk
== [1 2 3 4 5 6]


My version (gives the same result as kcollins, but is in-place like 
Geomol's) only flattens one level:
>> blk: [1 [2] [3 [4]] [5 6]]          
== [1 [2] [3 [4]] [5 6]]
>> forall blk [blk: back insert blk also blk/1 remove blk]
== [6]
>> blk
== [1 2 3 [4] 5 6]
Graham
18-Nov-2009
[15043]
>> to-block form [ [ 1 [ 2] 3 ] [ 4] ]
== [1 2 3 4]
Chris
19-Nov-2009
[15044]
Another, from the 'parse school:

	parse block [
		any [block: any-block! (insert block take block) :block | skip]
	] head block
Maxim
19-Nov-2009
[15045]
this should be a native in R3... there are MANY places where this 
is both needed and its always slow.
Graham
20-Nov-2009
[15046x2]
I've got some gui code which I am loading from a text string, and 
then running it.  I am binding it to some local words which I want 
to use and that works fine.

But I also want to invoke functions in the global context and it 
can't find them.  What to do?
eg. the text is

button "test" [ alert "hello" ]

and I get an error clicking on the button.
Chris
20-Nov-2009
[15048]
Bind the loaded text to a global word first ('system ?) then to your 
local context.
Graham
20-Nov-2009
[15049]
So, here, how would I get this working?


test: func [ /local lo ][ lo:  {button "test" [ alert "hello" ]} 
view layout to-block lo ]
Chris
20-Nov-2009
[15050]
test: func [ /local lo ][ lo:  {button "test" [ alert "hello" ]} 
view layout bind to-block lo 'all]
Graham
20-Nov-2009
[15051]
Let me try that ...
Chris
20-Nov-2009
[15052]
Just don't use 'all in your local context.
Graham
20-Nov-2009
[15053]
currently I am binding the block to some local words in the context
Chris
20-Nov-2009
[15054]
Bind to 'all first, then your local word(s)
Graham
20-Nov-2009
[15055]
eg ...