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

World: r3wp

[Core] Discuss core issues

BrianH
6-Jul-2010
[17273x2]
One caveat to new options: Once APPLY is backported (planned for 
2.7.8) then new options will need to be added to the end of the options 
list of functions, not in the middle. APPLY is positional when it 
comes to options.
This is already a concern for those using the R2/Forward backport 
of APPLY.
Pekr
8-Jul-2010
[17275x2]
What is the easiest way to prevent sub-object sharing? I have very 
simple but nested XML structure, and I want to put records into objects. 
But I have one subobject. I want to have prototype object (class) 
and create instances filled with data, but I want to avoid subobject 
sharing ....
simply put: proto: context [name: none address: context [street: 
none]], and now I want to make instances, but those should not share 
address subobject ...
Anton
8-Jul-2010
[17277]
You're going to have to clone the subobjects, eg.
	instance1: make proto [
		address: make address []  ; Clone object to avoid sharing.
	]
Ladislav
8-Jul-2010
[17278]
Just define your own constructor, that is all
Pekr
8-Jul-2010
[17279]
Ah, thank you very much ... I thought I could somehow avoid that, 
but that's ok ....
Maxim
8-Jul-2010
[17280x2]
I put an init function in the class, and do any stuff there, then 
its much easier to manage.

a: make class [init]
you can also make a function which call init , if its there.


new: func[class spec /local obj][obj: make class spec if function? 
get in obj 'init [obj/init]]
Steeve
8-Jul-2010
[17282]
if you keep the prototype as a block you don't need to do so
>> context proto
Ladislav
8-Jul-2010
[17283]
Nevertheless, the "use your own constructor" variant is the only 
"truly object-oriented" one
Maxim
8-Jul-2010
[17284]
yes, my above one-line constructor func scales very well, since you 
can call new on sub-objects too, and it will take care of any things 
like creating empty new blocks and formatted strings on the fly, 
within the init func.
Ladislav
8-Jul-2010
[17285x2]
My suggestion would be more like:

my-class: make object! [
    new: func [...] [...]
]

my-class-instance: my-class/new ...
, but, you can use whatever suits your needs
Maxim
8-Jul-2010
[17287]
yes, the power of rebol to define our own models  :-)
Henrik
10-Jul-2010
[17288]
How is it again that one decodes a url? Sometimes I forget the simple 
things.
Graham
10-Jul-2010
[17289]
dehex ?
Henrik
10-Jul-2010
[17290]
thanks
amacleod
10-Jul-2010
[17291]
Is there something like "unmold"? I find myself needing to return 
a molded block back to a block all the time.
Henrik
10-Jul-2010
[17292]
load
amacleod
10-Jul-2010
[17293]
dope
Henrik
10-Jul-2010
[17294]
remember to MOLD/ALL if you don't want to lose information.
Demitri
10-Jul-2010
[17295]
I have r2 question.  I wont to convert integer value to binary but 
it comes out wrong.  Some tell me how?  The integer is above 255.
Graham
10-Jul-2010
[17296]
Tell us what you are doing
Demitri
10-Jul-2010
[17297]
I trying to convert integer value to binary.
Izkata
10-Jul-2010
[17298]
>> debase/base to-hex 512 16
== #{00000200}
Demitri
10-Jul-2010
[17299]
thx you Izkata.
Anton
10-Jul-2010
[17300]
Dope doesn't work that well.
Ladislav
14-Jul-2010
[17301]
I think, that everybody processing REBOL strings using REBOL shall 
be aware of CureCode #1632. I should probably write an article about 
the subject somewhere to make life of at least some people easier.
Anton
14-Jul-2010
[17302]
Yes, it's a pity MOLD isn't the one which is the least "lossy" (vs 
MOLD/ALL) when it comes to serialising.
What can be done about it at this stage, though?
Maxim
14-Jul-2010
[17303x2]
thing is load isn't the counterpart to mold.  'DO is.   and even 
then, even MOLD/ALL isn't a real serialization because shared objects, 
or series aren't shared anymore.


although they go a long way, and I have been using them extensively 
in many tools, MOLD & MOLD/ALL are just helpers, destined for advanced 
users who have very special requirements.
we need to build a REAL serialization dialect, one which rebuilds 
the data sharing, even in nested and co-occuring references to series 
and objects.
Steeve
14-Jul-2010
[17305]
it's rebin
Maxim
14-Jul-2010
[17306x2]
but we should not be forced to use a binary dataset for such things. 
 it can be expressed in source format.
just added an (very succinct) extended serialization example which 
would allow us to basically fix all the MOLD issues on LOAD directly. 
 it could be the basis for rebin, which could just be a compressed 
version of the source version to keep it (very) small.
Steeve
14-Jul-2010
[17308]
just added ?
Maxim
14-Jul-2010
[17309x5]
to curecode.
as usually, all datatypes would need to support this extended format, 
but since it would be managed directly within the native datatype 
handling it would be MUCH faster than if we tried to build some dialect 
for it in REBOL.  especially since the native has much more direct 
access to things like same?, and internal states like series index.
I have done some work on this to support reloading of shared & nested 
objects specifically and its easy enough to do (for me ;-), but it 
requires some deeper understanding of REBOL.


I agree with Ladislav, though, that serialization should be addressed 
more "completely" at some point, directly within the language. 


IMHO, The current implementation isn't a "bug" but rather an annoying 
limitation which has been known and put off as a "to do" for years, 
by everyone which is capable of solving it.
(cause its a very tedious and "not fun" thing to do)
also, there are nasty binding issues on serialization...  things 
like:

---------------------------------
a: "data"
f: does [print a]
o: context [
	a: "other data"
	f: does [print a]
]
set in o 'f :f
---------------------------------


how is this treated in MOLDing ?  these are hard cases to choose 
from a variety of paths, if we serialize only the o  object, then 
its f method is pretty much broken in current REBOLs.   

how would we handle this?  there are a lot of ways to play with the 
above, but no single method will ever cover all possibilites.  


so in the end, the serialization will never be "perfect", unless 
all data items are signed with a unique key which is retrievable 
at run-time and reusable at each interpretation (pretty much impossible).


IMHO all we can do is properly document  what can and cannot be serialized 
without risk of data corruption.  Currently, official & explicit 
documentation on this is vague at best.
Ladislav
14-Jul-2010
[17314x2]
Max, I had a specific issue in mind: (pre)processing of REBOL scripts. 
In that case, you we not need to worry about such issues as binding, 
shared objects, etc. I am quite comfotable with MOLD, since it does 
not look like a gotcha to me (not that I want to repeat that "MOLD 
is not a counterpart to LOAD" mantra), but SAVE clearly *is* a gotcha, 
since nobody sane would expect it to "distort" REBOL script when 
saving REBOL code obtained as a result of LOAD.
you we not
: "we do not"
Maxim
14-Jul-2010
[17316]
in R3, there is save/all which stores in serialized format, which 
might solve that particular case (saving a whole script)
Ladislav
14-Jul-2010
[17317]
{I agree with Ladislav, though, that serialization should be addressed 
more "completely" at some point, directly within the language.} - 
I do not need that, especially not in this case; but I do want to 
help people to not get caught by the bad design decision making SAVE 
inadequate for the task it is supposed to perform.
Maxim
14-Jul-2010
[17318]
actually it seems even R2 has /ALL refinement.
Ladislav
14-Jul-2010
[17319x2]
Yes, that is not a problem, problem is, that almost everyone would 
expect SAVE to be adequate.
Ceterum censeo Carthaginem esse delendam

 - the SAVE function (especially in R3) should work as SAVE/ALL does, 
 while the "gotcha functionality" should be discarded.
Maxim
14-Jul-2010
[17321]
but SAVE/ALL will distort the output such that many values such as 
true and none  will be written in their serialized (and ugly) format 
of #[true] and #[none]  so that is not optimal either.
Ladislav
14-Jul-2010
[17322]
Are you kidding? Try to load any script and save it