World: r3wp
[Core] Discuss core issues
older newer | first last |
Anton 3-Apr-2008 [10106] | Try this: make object! [a: 1 + 2 print "hello"] |
Henrik 3-Apr-2008 [10107] | then I don't understand: "mold/all, on the other hand, does not evaluate the object spec block.". should that not produce a lit-word in the object? |
Anton 3-Apr-2008 [10108x2] | You can see both the expression 1 + 2 and print "hello" are evaluated. |
Sorry, I meant when you evaluate the result of mold and mold/all. | |
Henrik 3-Apr-2008 [10110] | What doesn't make sense to me is that MOLD presents the lit-word. I don't really care that they mold and load the same and what is evaluated after MOLD. It's MOLD itself that bothers me. :-) |
Anton 3-Apr-2008 [10111x6] | Ok, first of all, trust me that the way it is is just perfect. Now, I have to think how to explain it well.. |
A first explanation attempt :- MOLD's basic task is to provide the specification for the value being molded, so that, when DOne you get the original value. MOLD/ALL's basic task is to provide the specification for the value being molded, so that, when LOADed, you get the original value. | |
The difference is, do [ make object! [...] ] will evaluate whatever is in the spec block, whereas do [ #[object! [...] ] will not, no matter how many times you try it. | |
The first one relies on 'make being evaluated as the default native MAKE function that we all know and love, and the second one does not. A simple load is all that is required to build the object. | |
MOLD/ALL works straight from the the object itself, whereas MOLD/ALL goes "back further", returning code which *produces* the specification. | |
The best explanation should probably come from a sound definition of mold and mold/all.... | |
Henrik 3-Apr-2008 [10117] | you wrote MOLD/ALL in both cases in the line above. |
Ingo 3-Apr-2008 [10118] | I guess you meant "MOLD goes back further" |
Henrik 3-Apr-2008 [10119] | As I read here, I understand it. I also think that it would have been better for MOLD/ALL to be called SERIALIZE, because it is not an extension of MOLD, but perhaps a different mode. But I bet that Carl already has thought about this. |
Anton 3-Apr-2008 [10120x2] | Ingo, yes. |
As I remember, there was some debate about what to call mold/all when it was developed. We could probably just search some archives to find out... | |
Gregg 3-Apr-2008 [10122x2] | SERIALIZE implies to me that there would be a target to serialize to, which is SAVE. |
i.e. SAVE/ALL | |
Anton 3-Apr-2008 [10124x2] | disagree - check the expression "serialise to disk" |
serialise means "turn into a series" ie. a string. That's all. | |
[unknown: 5] 4-Apr-2008 [10126x7] | I have been thinking about this for sometime. I'm thinking we need an alternative set of mezzanines for those that need performance and want to build something off the /base product. Problem with existing mezzanines is that they need to maintain backwards compatibilitiy which means we may lack some of the performance we might gain from a current alternative. The goal of the new set of mezzanines is to be driven from the most recent distribution of the REBOL platform R2. Obviously, R3 should be accomplishing this task inherently. |
However, would anyone use them? Or would they just code as needed if they are going to use the /base product anyway? | |
Just some things to think about. | |
Kind of a niffty way to hide some code that I have been playing around with lately but it isn't full proof: | |
a: [] append a use [b][b: context [c: "Cool"] does [b/c]] d: first a | |
>> d == "Cool" | |
>> source d d: func [][b/c] | |
Anton 4-Apr-2008 [10133] | Essentially: d: does bind [print c] context [c: "Cool"] |
[unknown: 5] 4-Apr-2008 [10134] | Yep. |
Anton 4-Apr-2008 [10135x2] | >> d Cool >> source d d: func [][print c] |
But, like your version, if we can get the word, we can get its context: >> probe do bind [self] second second :d make object! [ c: "Cool" ] | |
[unknown: 5] 4-Apr-2008 [10137] | yep it can never be full proof in R2 as far as I know. |
Anton 4-Apr-2008 [10138] | fool proof |
[unknown: 5] 4-Apr-2008 [10139] | ahhh wasn't sure, lol |
Anton 4-Apr-2008 [10140] | actually "foolproof" |
[unknown: 5] 4-Apr-2008 [10141] | maybe fool-proof? |
Anton 4-Apr-2008 [10142] | full proof pertains to strength of alcohol. |
[unknown: 5] 4-Apr-2008 [10143] | indeed |
Anton 4-Apr-2008 [10144] | Well... we can unset 'self, so that the above method does not work: >> do bind [unset 'self] second second :d >> probe do bind [self] second second :d ** Script Error: self has no value ** Near: self |
[unknown: 5] 4-Apr-2008 [10145] | does that hide it completely? |
Anton 4-Apr-2008 [10146x2] | I haven't tested that much at all, so I don't know if that would break anything as rebol goes along... |
I'm not sure if there is another way in, quite possibly there is. | |
[unknown: 5] 4-Apr-2008 [10148x3] | Even if it does it might be useful in controlled situations. |
I know you can hide some things by simply declaring an object and afterwards setting the objects self to a different value | |
>> a/self: 3 == 3 >> a >> probe a make object! [ b: 2 ] >> a/self == 3 | |
Anton 4-Apr-2008 [10151x2] | See my code above. |
That still doesn't stop BIND? actually... Need to unset 'bind? as well :) | |
[unknown: 5] 4-Apr-2008 [10153] | that could cause way to many problems I would assume. |
BrianH 4-Apr-2008 [10154x2] | If your code can reference a word, then code that treats your code as data can reference the word in R2. |
If you want to sandbox R2, you have to sandbox the functions that can turn your code into data - that means the ordinals. | |
older newer | first last |