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

World: r3wp

[Core] Discuss core issues

Ladislav
25-Jul-2011
[1894x2]
The Data exchange dialect (or the Load dialect) is incoplete in the 
following sense:


- natives etc. do have specially escaped representations (MOLD/ALL 
creates them), but such representations are not loadable

- MOLD/ALL creates loadable representations of REBOL objects and 
functions, but they are not guaranteed to preserve the properties 
of the orignal values
The "incomplete" above means "incomplete when compared with the DO 
dialect".
Geomol
25-Jul-2011
[1896x4]
natives etc. do have specially escaped representations (MOLD/ALL 
creates them)

>> native? :until
== true
>> mold/all [until [true]]
== "[until [true]]"

How do I see the escaped representation?
>> mold/all :until             
== "native"

Hm, how is this useful?
Why not do this instead of having constructs?

>> make logic! 0      
== false
>> make logic! 1
== true
>> make none! 0 
== none

... etc.
Sorry I answer myself, but it's probably because it gives a different 
kind of value when loaded:

>> load {make logic! 0}
== [make logic! 0
]
>> load {#[false]}     
== false
Ladislav
25-Jul-2011
[1900x6]
How do I see the escaped representation?
 - interesting, you seem quite seriously confused
the [until [true]] block contains only words
>> mold/all :until
== {#[native! [[
    "Evaluates a block until it is TRUE. "
    block [block!]
]]]}
It is from R3, but, as said above, it is not loadable
Why not do this instead of having constructs?

>> make logic! 0      
== false

, because it is confusing. I prefer this:

>> display-result make logic! 0
== #[false]
(see the DISPLAY-RESULT function above)
Geomol
25-Jul-2011
[1906]
I guess, much of my confusion here comes from the fact, that I never 
had the need for constructs.


If we follow the thought, that the none value should be shown as 
#[none] in the console, when it's a result, then the following should 
be shown as well:

>> next "abc"
== #[string! "abc" 2]


I think, most people wouldn't want that. It's not very readable. 
I still ask myself, if all those constructs are really necessary 
taking the amount of work and time used into account.
Henrik
25-Jul-2011
[1907]
I see them as necessary, otherwise you would not be able to serialize 
(or specially escape) any rebol code or data properly using a fixed 
method. This is very important for dialects.
Geomol
25-Jul-2011
[1908]
Henrik, can you give a simple example, where the serialized format 
is needed?
Henrik
25-Jul-2011
[1909]
every time I save REBOL data to disk? I use this hundreds of times 
every day.
Geomol
25-Jul-2011
[1910]
What's wrong with using a simple SAVE?
Henrik
25-Jul-2011
[1911]
you will lose every datatype that will be seen as words.
Geomol
25-Jul-2011
[1912]
Not, if you LOAD the data back into a context, where those words 
have meaning.
Henrik
25-Jul-2011
[1913x2]
no, some types may be *confused* as words. that's different.
Basic example:

>> save %file.txt none
>> load %file.txt
== none ; is it none?
>> type? load %file.txt
== word! ; nope
>> save/all %file.txt none
>> type? load %file.txt   
== none! ; yes, only with proper serialization
Geomol
25-Jul-2011
[1915x2]
It's kinda interesting, how complexity sneak into a language like 
REBOL. I have never used constructs. I save REBOL data and code to 
disk all the time. I even created a file system/database, that is 
all about saving and loading data and code. I get along using a combination 
of simple REBOL functions like SAVE, LOAD, REDUCE and DO.
I understand, it can be argued, it's more simple to just use
	save/all ....
	load ...

than something like
	save ...
	do load ... or maybe ... reduce load ...


but trying to make this simple result in a much more complex language. 
(as I see it)
Henrik
25-Jul-2011
[1917]
I'm not sure that's a complexity. It's a basic need, when transfering 
REBOL data somewhere else, using strings or binaries. There is simply 
a loss of information, if the data is transferred in an unserialized 
fashion.
Geomol
25-Jul-2011
[1918]
As code is also data in REBOL, and because natives can't be loaded 
and there are bugs like in making function constructs, then I see 
this as half-hearted. It kinda work, but not really.
Henrik
25-Jul-2011
[1919]
You can't avoid serialization. What does this block contain?

>> my-block
== [none none]


You simply don't know by looking at it and you can't use this information 
other than in the current context. If you need to transfer the data 
elsewhere, you must serialize it.
Pekr
25-Jul-2011
[1920]
Geomol - you should seriously serialise :-)
Geomol
25-Jul-2011
[1921x5]
heh
Well, Henrik, I suppose the none word holds the none value, and if 
it does, it probably works as intended. If people want to redefine 
none, then it would mean something else. And then what? I don't see 
a big problem needing constructs in there.
If a writer write
	fromage

what does that mean? In Denmark, it's a dessert, in France, it's 
cheese.
So I need to seriealize that word to hold the meaning?
Nah, I don't think so.
The meaning comes from the context.
Ladislav
25-Jul-2011
[1926]
Interesting, that after writing

    mold/all [undo [true]]


and wondering why you did not obtain what you expected you still 
don't see that you confused words and the possible values that may 
have been assigned to them.
Henrik
25-Jul-2011
[1927]
Geomol, the context is not relevant during serialization, so stating 
that "I suppose the none word holds the none value" is incorrect. 
It is the unreduced contents that are important. Also you don't have 
the index of the block.

Let me reveal what my-block actually contains:

my-block: next reduce [true none 'none]


That information is only available in the serialized format like 
this:

>> mold/all my-block
== "#[block![#[true] #[none] none]2]"
Geomol
25-Jul-2011
[1928]
Yeah, I wasn't very sharp, when I wrote that mold/all example, Ladislav. 
:)
Ladislav
25-Jul-2011
[1929]
As I see it, the problem is not that you "wasn't very sharp", the 
problem is, that the practice of displaying words and their values 
the same way *is* confusing.
Geomol
25-Jul-2011
[1930x2]
That information is only available in the serialized format like 
this:

Why isn't it available using the do dialect, like:
	do [next reduce [true none 'none]]


And then you say, because DO, NEXT and REDUCE may not hold the meaning, 
you expect. 2 points:


1. Right, but is it worth the effort, if those are being redefined?

2. Why SAVE series like that at all? Why not save HEAD series and 
then maybe an offset, if you need it?
Ladislav, isn't it only confusing, if those words are redefined?

And redefining those words in the first place is confusing, so this 
bites itself in the tail.
Henrik
25-Jul-2011
[1932]
Geomol, you don't know how the data is generated, if you are getting 
the data from disk or network, where you are surely not haplessly 
DOing things for security reasons. You are capturing the state of 
the data. Without such a state capture, much of REBOL is rendered 
useless.
Ladislav
25-Jul-2011
[1933x2]
Ladislav, isn't it only confusing, if those words are redefined?
 - no, and the example you used demonstrates that
(I mean the mold/all [undo [true]] example)
Geomol
25-Jul-2011
[1935]
So, to constrain this, constructs are useful for values, you don't 
wanna do (because of security reason, if e.g. the data came over 
the network). Therefore there is no need to make constructs for natives, 
operators and functions?
Henrik
25-Jul-2011
[1936]
there are constructs for functions. natives and ops can obviously 
not be serialized and don't need to.
Geomol
25-Jul-2011
[1937x2]
What if you want to send this information:
	[next "abc"]
, where next is the native NEXT ?
If you can't serialize NEXT, it can mean anything, right?
Pekr
25-Jul-2011
[1939]
then you send it, and when loaded, 'next is executed, no?
Geomol
25-Jul-2011
[1940]
Eh, no.
Henrik
25-Jul-2011
[1941]
Geomol, you can't present NEXT that way. In that block, it will be 
a word:

>> reduce [:next]
== [action]
Geomol
25-Jul-2011
[1942]
Ok, confusing with the block. Forget that.


What if you wan't to send the information: evaluate the native NEXT 
working on the string "abc" ?
Henrik
25-Jul-2011
[1943]
simply send the block [next "abc"] and DO it in the other end (if 
you dare)