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

World: r3wp

[!REBOL3-OLD1]

Pekr
4-Sep-2009
[17155]
Robert - do you need such lazy evaluation? I mean - even 'alias seems 
being removed from R3. Don't we have enough of reflectivity? Anyway 
- anyone who imo wants to propose something, should definitely do 
so in terms of CureCode or R3 Chat, or Carl WILL NOT know about the 
request at all, and your only chance here will be BrianH :-)
BrianH
4-Sep-2009
[17156x5]
Robert:

1. The extension interface is currently single-threaded, but that 
shouldn't affect what the DLL does inside itself.

2. Devices are the standard R3 method of handling asynchronous behavior. 
Though the extension interface currently doesn't support the creation 
of devices, that is intended to be supported next. Maxim's callbacks 
may be supported too, but what you are talking about is a job for 
devices.
Geomol, the main problem with sharing is doing it in a manageable 
way. The advantage of using explicitly shared contexts is that you 
can know where your values are and distingish them from non-shared 
values.


Your idea about a different word type for shared values won't work 
because words don't actually contain anything. All values are stored 
in contexts, blocks or type-specific containers. All values "assigned 
to words" are contained in contexts, no exceptions. Even function 
words are associated with contexts. The question is which one.

R3 has two context types already:

- object!: Similar to system/words in R2, though for some internal 
instances (like error!) expansion is blocked. Direct reference.

- function!: Not expandable, stack-relative reference. Task and recursion 
safe.


Closures have object-style contexts, with a new instance created 
with every call (with bind/copy overhead on the code block, sort-of).
There will be ways to make object word references more task-safe, 
but that isn't implemented yet. Focus on that: it's the real problem.
Robert, you can do lazy evaluation using functions that replace themselves 
with their results. Anything more requires a full language semantics 
overhaul, and might not be possible in an interpreted language. What 
do you hope to accomplish?
Most algorithms that would benefit from laziness are done in REBOL 
using code blocks or get-word parameters.
Steeve
4-Sep-2009
[17161]
Btw, who is Robert ? Geomol ?
BrianH
4-Sep-2009
[17162]
Right-click on their names. They've been here for a while :)
Steeve
4-Sep-2009
[17163x2]
Sorry, i was seeking the post related to laziness from Robert and 
didn't found it....
I was wondering if Geomol was Robert
BrianH
4-Sep-2009
[17165]
Geomol is John. Robert's laziness post starts with "Geomol, regarding 
1".
Steeve
4-Sep-2009
[17166x2]
yep, found it now
Sort of...


lazy: funco [code][does reduce [first back stack/block 2 to-paren 
code]]
c: context [
	a: lazy [b + c]
	b: lazy [c + 5]
	c: 2
]


>>probe c
==make object! [
    a: make function! [[][
        a: (b + c)
    ]]
    b: make function! [[][
        b: (c + 5)
    ]]
    c: 2
]

>> c/b
== 7
>>probe c
>>make object! [
    a: make function! [[][
        a: (b + c)
    ]]
    b: 7
    c: 2
]

>>c/a
==9
>> probe c
==make object! [
    a: 9
    b: 7
    c: 2
]
BrianH
4-Sep-2009
[17168x2]
I was thinking named functions assigning results to their names, 
but with debug access that way will work too :)
I used a similar method to write the ONCE function.
Geomol
5-Sep-2009
[17170x6]
Steeve, who are you?
Robert: http://www.colellachiara.com/devcon05/robert.html
Me: http://www.colellachiara.com/devcon05/john.html
Brian wrote "Your idea about a different word type for shared values 
won't work because words don't actually contain anything."


Don't say, it won't work. It can be made to work, if the will is 
there. I can think of many different possible implementations of 
REBOL with the current behaviour, we see. As I don't know, how exactly 
REBOL is implemented (I guess, only Carl does), I won't go in detail 
how to do, what I propose. Anyway, I personal feel, it might NOT 
be worth the efford to implement, what a programmer would observe 
as shared words. The C code will be more complex, and it will probably 
hit performance to some degree. Shared contexts within contexts as 
in R2 is probably just fine. Only problem (as I see it) in R2, is 
that it's difficult to not share contexts within contexts. But the 
R3 possibility to copy contexts can solve that. I think, the current 
R3 implementation of contexts (objects) and the copy semantics is 
far too complex.
Someone named Nick suggested having make/deep:
http://www.rebol.net/cgi-bin/r3blog.r?view=0239#comments

This could remove the need for copying contexts:

new-object: make/deep old-object [ ... ]

instead of what we have to do now:

new-object: make copy/types old-object any-type! [ ... ]
But the /deep refinement for make would only be used with objects, 
and it's maybe not ok to add a refinement to a function, if it's 
only to be used with one certain type of argument?
If not, then it could be solved with a new function: make-deep, make-new 
to something.
From time to time I ask myself, why I write so much about all this. 
It's because I care for the language, and I see many stange implementation 
decisions, and that's not good.
Steeve
5-Sep-2009
[17176]
Geomol, my question was poorly worded.

I was wondering why Brian called you Robert (i didn't see the previous 
post from Robert)
Geomol
5-Sep-2009
[17177x2]
Ah, ok! :-D
Oh my, it's not even enough to just copy/types, I have to do copy/deep/types 
to get a completely new object:

new-object: make copy/deep/types old-object any-type! [ ... ]

Does that look simple? No!
Steeve
5-Sep-2009
[17179]
you just need to make a wrapper.

>>make-full: funco [obj spec][make copy/deep/types obj any-type! 
spec]

Is this such a pain in the ass ? ;-)
Geomol
5-Sep-2009
[17180]
Yeah! I then need to remember to include this function in all my 
code. It would be better, if the language just did it right in the 
first place. ... time to make my own language. ;-)
Steeve
5-Sep-2009
[17181]
Ask Brian for a mezzanine :-)
Robert
5-Sep-2009
[17182x3]
Lazy: Let's assume I have a quite complex evaluation graph with 100 
input parameters. Think of it like an Excel spreadsheet. Now what 
I want is that if one parameter changes, that all dependent parts 
are re-evaluated. Like Excel does it.
Maybe a constraint solver is  the better word
The problem with Excel is that you can create complex calculations 
quite easy but if you are not the author, doing a reverse engineering 
is tedious. Having an excel like model available on the language 
level would IMO be very nice.
Steeve
5-Sep-2009
[17185]
i can work on it, what form of evaluation graph do you expect ?
BrianH
5-Sep-2009
[17186x2]
Geomol, I'm not saying that what you want can't be done, I'm saying 
that you would be creating a new context type, not a new word type. 
The type of a word doesn't in any way affect the behavior of value 
slots that the word might refer to, but the context type does.


However, I don't think that a new context type would be needed here, 
because the object! context is shared by default. The only thing 
you are affecting is whether prototype fields would be shared amongst 
derived objects, or copied. You could easily implement this kind 
of sharing using a mezzanine like FUNCT (not FUNCT, but another mezzanine 
with a similar implementation). There would be no performance degradation 
on use of the shared words, and only minimal at creation time. The 
reslting code would be semantically equivalent to the R2-style shared 
inner object model, but the code wold be simpler.
For that matter, FUNCT/with implements something similar to what 
you request, but with functions instead of derived objects.
Pekr
8-Sep-2009
[17188x2]
BrianH: in regards to #1228 - how can you access unnamed module by 
path notation? I mean - normally you can access unexported values 
by module-name/value, no?
(I probably need to start using them in real-life :-)
BrianH
8-Sep-2009
[17190x3]
You need to import a module explicitly using IMPORT if you want to 
use path notation.
For the most part, you don't access unexported module variables, 
and don't use path notation. Minimal programmer overhead.
I had to do some interesting tricks to get mixins to work, but they 
do work well.
Pekr
8-Sep-2009
[17193]
Can I have protected module members? I mean - non accessible by path 
notation?
BrianH
8-Sep-2009
[17194x2]
PROTECT/hide, or inner contexts.
Modules are for code organization, not information hiding. You generally 
protect stuff using PROTECT - it works better that way.
Pekr
8-Sep-2009
[17196x2]
hmm, protect/hide - where do I call it from? At what stage? What 
about having header options - exports, imports, protects? :-)
Well, I probably think about them way too much as about objects. 
OTOH - I might have some module, but I want to hide my internals 
... kind of DLL aproach - you only provide docs with the accessible 
API and the rest should be hidden and even maybe signed ...
BrianH
8-Sep-2009
[17198x2]
PROTECT/hide is called in your code, generally in the code block 
of the module. It blocks binding. Once all of the code that you want 
to have access to the word has already bound to it, PROTECT/hide 
will prevent any future code from binding to it. You can't do traditional 
OOL protection because of the direct binding of REBOL, but PROTECT 
works pretty well (aside from stuff still in CureCode).
In general, R3 assumes that the developer who is creating the script 
is not an idiot, and knows what they want to do. If they want to 
lock things down then there are ways to enable that safely. Otherwise, 
it's as open as you want it to be. PITL doesn''t require that the 
system hide everything, just thaat it be possible to organize large 
systems. Protect what you need to.
Pekr
8-Sep-2009
[17200]
OK, so what is the possibility for developer to provide users with 
some secure = signed module, with protected internals and only providing 
users with exported API? Do I have to use extensions for that, and 
mangle my code somehow? Calling proted/hide in user app does not 
help module author, if he/she does not wish to release his code. 
My questions are theoretical - I will probably never write any such 
stuff, but I would like to imagine, how some business entinty could 
aproach this ...
BrianH
8-Sep-2009
[17201]
Signing a module only gives a user someone to blame if things go 
wrong - it isn't real protection. But I agree, code signing would 
be nice, especially for extensions since you can't just read the 
code very easily. The checksum support works for verifying the code 
matches what you expect though.


The module system is designed with security in mind, not closing 
the source. If you want closed source make an extension, or encrypt 
your REBOL source (like R2 encapping), or build your own host program 
(the R3 version of encapping), or download the source from a secure 
server and protect the words that refer to it so you can't get at 
it through reflection at runtime. REBOL still isn't compiled, sorry.
Maxim
8-Sep-2009
[17202x2]
would creating a module within an extension's mezz code section effectively 
count as a closed module? is it even possible?
(sorry for not joining discussion earlier... I've been offline for 
almost a week due to my DSL modem going bust)
BrianH
8-Sep-2009
[17204]
An extension's mezz code is itself a module, and its source is as 
closed as you can make any source that is embedded in native code.