Anton wrote:
> You know how other languages have a statement like this:
>
> with (obj){
> name = "object 1"
> size = 23
> }
>
> which is to access elements of the obj object, without having to use a
path notation like: obj/name obj/size etc. Does rebol have anything like
this?
Yes.
> Could a function be built into an object that accepts a block of code and
does it inside the object, therefore no longer needing to explicitly refer
to obj/name, just name, etc ?
Yes.
> For example, if the special function is called 'with, the call would be
something like:
>
> obj/with [name: "object 1" size: 23]
>
> The code then gets done inside the object. This should be equivalent to:
>
> obj/name: "object 1"
> obj/size: 23
>
> It's not urgent, just interesting. (My little attempt just now failed. ->
with: func [code][do code])
>> o: make object! [
[ reverse_add: func [a b][print b - a]
[ Dialect: func [Dialect [block!]] [
[ do bind Dialect in self 'self
[ ]
[ ]
>> o/Dialect [reverse_add 5 9]
4
See:
http://members.nbci.com/AndrewMartin/Rebol/Units/HTML.r
for a practical example.
Andrew Martin
ICQ: 26227169 http://members.nbci.com/AndrewMartin/
-><-
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.