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

World: r3wp

[Core] Discuss core issues

sqlab
19-Feb-2009
[12418]
Why you do not make your template just an unevaluated block and then 
you always generate a new object or you never change your template, 
just the descendants ?
DideC
19-Feb-2009
[12419x2]
Its by design : subojbect are not copied by 'make. All R2 VID is 
build on this concept (shared objects).
You need a 'make-deep function that (recursively ?) digg into the 
copied object and copy each subobject it find. I'm sure people arround 
have one in their HD (not me).
TomBon
19-Feb-2009
[12421x3]
paul, makes no difference..sqlab, wrap the object into a unevaluated 
block?
DideC, yes I guessed that. thx
a copy/deep second or third object! doesn't work either.
[unknown: 5]
19-Feb-2009
[12424]
Have you considered using a construct?
TomBon
19-Feb-2009
[12425x2]
paul, I never used construct. can it serve nested constructs also?
will take a look into the docs about it...
Graham
19-Feb-2009
[12427]
does this work?

create-template: func [ d [integer!]
] [
	make object! [
		obj-in-obj: 	make object! [a: make integer! d]
		b: 		make integer! 0
		c: func [val] [
			obj-in-obj/a:   val
			b:		val
		]
	]
]

a: create-template 0
b: create-template 1000
probe a
probe b
b/c 3000
probe a 
probe b
[unknown: 5]
19-Feb-2009
[12428x2]
TomBon, here is the construct docs http://www.rebol.com/docs/changes.html#section-4.1
TomBon, here is the purpose of a construct:

>> ct: construct [int: (1 + 1)]
>> ct/int
== (1 + 1)
>> do ct/int
== 2
>>


Notice that it doesn't automatically evaluate /int as an object would 
do.
TomBon
19-Feb-2009
[12430x2]
YES! thx a lot graham and paul. it works.
yepp, just made a check with real data. works fine. again thx for 
help...
Graham
19-Feb-2009
[12432]
Now, you have to tell us why it works :)
TomBon
19-Feb-2009
[12433]
you have read my mind graham :-) but to be honest I have no idea. 
does the function preserve the scope?
Graham
19-Feb-2009
[12434x2]
I have no idea :)
Where is the parent object now?
TomBon
19-Feb-2009
[12436]
:-)) well sounds thrustfull to built a comercial software on that 
;-)
Graham
19-Feb-2009
[12437]
I presume it's recreated anew each time the create-template runs
TomBon
19-Feb-2009
[12438]
encapsulated within the function space?
Graham
19-Feb-2009
[12439x2]
You still can't clone from the objects it creates ...  ie. e: make 
a [] has the same problems
the parent object is an unevaluated block
TomBon
19-Feb-2009
[12441]
do you think this solution is stable?
Graham
19-Feb-2009
[12442x2]
it doesn't exist as an object.
so, this is sqlabs solution
TomBon
19-Feb-2009
[12444x2]
the object! will be a central part for the lib I am currently building.
wow, fractal programming at it's best
Graham
19-Feb-2009
[12446]
sure it's stable.
TomBon
19-Feb-2009
[12447]
cool
[unknown: 5]
19-Feb-2009
[12448x2]
TomBon, keep in mind that you can create the spec for an object and 
use it as your template as well.
>> blk: [a: 1 b: 2]
== [a: 1 b: 2]
>> obj: context blk
>> obj/a
== 1
>> obj/b
== 2
Graham
19-Feb-2009
[12450]
If you look at the source for 'function, you will see that the parameters 
are just 2 blocks ....
TomBon
19-Feb-2009
[12451]
yes but the objects also containing functions and nested objects 
etc. graham approach is very compatible with the current codebase 
I have so far but thx for reminding me with this paul.
[unknown: 5]
19-Feb-2009
[12452]
Your welcome TomBon, glad to see that you got the problem resolved.
[unknown: 5]
21-Feb-2009
[12453]
What part of this is a bug:

>> val: 'blah
== blah
>> type? val
== word!
>> lit-word? val
== false
>> help val
VAL is a word of value: blah
>> val: to-lit-word val
== 'blah
>> type? val
== word!
>> lit-word? val
== false
>> help val
VAL is a lit-word of value: 'blah
Anton
21-Feb-2009
[12454]
Lit-words reduce to words pretty easily, so try this instead:
	type? :val
[unknown: 5]
21-Feb-2009
[12455x4]
Yeah I actually realized that after I posted it.
What was confusing me is assignment and how it works with lit-word
Consider the following:

>> a: 'test
== test
>> lit-word? :a
== false
>> a: to-lit-word 'test
== 'test
>> lit-word? :a
== true
Seems to me that the assignment aspect is still buggy.  i would expect 
to get lit-word? true on the first call in that example.
Izkata
21-Feb-2009
[12459]
The way I see it:

In your second post,

'test is a lit-word! being evaulated to a word! before assignment 
to 'a, in the first part

In the second part, the lit-word! 'test is being evaluated to a word!, 
passed into the function to-lit-word, then the lit-word is assigned 
to 'a


In the first post, why "type? val" returns word! on a lit-word!, 
I see as the same as this - the type is a subset:
>> X: %One
== %One
>> type? X
== file!
>> series? X
== true
[unknown: 5]
21-Feb-2009
[12460x2]
It just seems inconsistent to me but I suppose it is needed to be 
this way to deal with the manner in which REBOL operates.  For example, 
consider its inconsistency in this regard:

>> string? "this"
== true
>> file? %file
== true
>> lit-word? 'this
== false
Also consider this:

>> a: first ['test]
== 'test
>> lit-word? :a
== true
>>
Izkata
21-Feb-2009
[12462]
It's always felt consistent to me - the context is being evaluated, 
and lit-word!s reduce to word!s, word!s reduce to functions and values, 
while other datatypes reduce to themselves:
>> X: [{One} 'Two]
== ["One" 'Two]
>> ? X/1 ? X/2
X/1 is a string of value: "One"
X/2 is a lit-word of value: 'Two

>> X: reduce X   ;Here is where typing it in on the terminal evaluates 
to
== ["One" Two]
>> ? X/1 ? X/2
X/1 is a string of value: "One"
X/2 is a word of value: Two
>> X: reduce X
** Script Error: Two has no value
** Near: Two

...and the reasoning behind lit-word!/word! acting differently is 
that those are special datatypes where other values can be bound 
to them
[unknown: 5]
21-Feb-2009
[12463x2]
My point is that I don't see why the to-lit-word isn't implied when 
performing assignment.  Such as a: 'test
BTW, it is more efficient to assign a lit-word with a: first ['test] 
then it is to use a: to-lit-word 'test.
Janko
21-Feb-2009
[12465x3]
(I participatted in this discussion already one time and it also 
seems consistent to me)
Paul: I think Brian or Henrik told that time that 'word is "active" 
something and rebol reduces it when encounters it in the same way 
as it would auto-reduce function a: get-two not assign it to a (at 
least that was my compilation of it that time :) )
and we all know that blocs don't get evaluated / reduced by itself 
so [ word ]  stays [ word ] even fi word is undefined or func or 
anything so [ 'word ] also stays [ 'word ]