[REBOL] Re: [Truth test fails]

2004-05-19 Thread Christian Ensel

Hi Tim,

| What would be the use for that feature?
|

It's usefull e.g. when you MOLD or SAVE what you want to LOAD easily:

 mold none
== none
 mold/all none
== #[none]
 type? load mold none
== word!
 type? load mold/all none
== none!

 save/all %/c/test.r none
 load %/c/test.r
== none
 type? load %/c/test.r
== none!

The same feature applies for objects, too:

 mold/all context [a: 5]
== {
#[object! [
a: 5
]]}
 type? load mold context [a: 5]
== block!
 type? load mold/all context [a: 5]
== object!

HTH,

Christian
-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] AW: frustrating pairs...

2004-05-07 Thread Christian Ensel

Dear Alain,

 either d = 'x [bx/pane/offset/x: - tmp * sf/data ] [ ; how to improve that
?
 bx/pane/offset/y: - tmp * sf/data ]

The function MIX-PAIRS as defined below takes two PAIR!s and a word of value
X or Y. Depending on the latter MIX-PAIRS returns a new PAIR! which is
composed by A's axis as supplied in the 'D argument and B's opposite axis.
This lets you 'simulate' touching only one axis easily.

Sounds very confusing, I know, but look at the following code snippet, you
will get the idea:

; cut'n'paste -- (beware of
line-breaks) -
REBOL []
mix-pairs: func [a [pair!] b [pair!] 'd [word!] /local way] [
  (a * way: pick [1x0 0x1] :d = 'x) + (b * reverse way)
]
scroll: func [bx sf 'd] [
  bx/pane/offset: mix-pairs bx/size - bx/pane/size * sf/data bx/pane/offset
:d

;^^^
  ;--  bx/pane/offset is modified only for the direction supplied in :d
  ;by setting the opposite axis back to the value before the
modification
  ;
  show bx
]
d: 'x
view layout [
  across bx: box 200x100 white with [
pane: make-face/spec 'box [size: 40x40 color: red]
  ]
  sf: slider 20x100 [scroll bx sf :d] return
  tg: btn toggle [d: select [x y x] :d
sf/data: bx/pane/offset/:d / (bx/size/:d - bx/pane/size/:d)
show [tg sf]
] ]
; cut'n'paste -- (beware of
line-breaks) -

regards,

Christian



-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: Bidirectional value mapping.

2003-11-03 Thread Christian Ensel

Hi Bruno,

doing it in the SELECT-way is nice but you should consider using it with the
/SKIP-refinement. Without this you may end up with surprising results if one
value may occur in value-1 and value-2 position as in 
;
 that's-life: [cats birds cats birds insects birds]
 who-hunts?: func ['animal] [select that's-life animal]
 who-hunts? birds
== cats
 who-hunts? insects
== birds
 prey-of?: func ['animal] [select that's-life animal]
 prey-of? cats
== birds
 prey-of? birds
== cats; OOPS!
;
  
The following design doesn't suffer from this difficulty and avoids
duplication of values, too, at the cost of a little bit more maintenance
work:

;
color-names:  [red green blue]
color-values: [255.0.0 0.255.0 0.0.255]
select-color-by-name: func [name [word!] /local color] [
if color: find color-names name [pick color-values index? color]
]
select-color-by-values: func [value [tuple!] /local color] [
if color: find color-values value [pick color-names index? color]
]
append-color: func [name [word!] value [tuple!]] [
append color-names  color
append color-values color
]
remove-color: func [name [word!] value [tuple!]] [
remove find color-names  name
remove find color-values value
]
;

A lot of improvements can be made to this, especially the REMOVE-COLOR is
somewhat bad designed in respect to data-integrity (try REMOVE-COLOR RED
0.255.0 - Hey, I'm color-blind ;-)
But what I like about the design this approach that it is easily expandable in
cases you have to deal with tuples of data of length greater than just 2.

HTH,

Christian 
 


-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: How to check function arguments? - Syntax REBOLution ...

2002-06-10 Thread Christian Ensel

Hi [Ladislav Romano Gabriele],

On monday, 10-Jun-02, 07:48:53, Ladislav Mecir wrote:

 my essay http://www.rebolforces.com/~ladislav/argstake.html describes how
 Rebol functions take their arguments.

Not that for one single moment I thought I've discovered a not so well-known
rebol behaviour ... ;) 

Thanks to you all for pointing me to this article,
regards,

Christian  

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with unsubscribe in the 
subject, without the quotes.




[REBOL] Re: pseudo-class inheritance at a price ?

2001-10-09 Thread Christian Ensel

Hello Christian,

 No answers here but something that would definitely entyice me to use the
 class methods!
 
 Hmm, I have to admit that I haven't been thinking about object over ip
 connection. However, since class are still object! and object-instance are
 object! too (in the rebol sense), I would expect to serve both class and
 object through a connection...

Whenever it comes to making OOP objects persistent - and at the very moment
I don't see too much of a difference between writing class instances to disk
and transferring them over networkobjects - there's the problem of correctly
identifing the class a object belongs to.

Now, while thinking about that today's evening I've had an idea (don't know
if someone had this idea too long before me, at least till now I never heard
of it :)
 
Instead of letting Joe User (Joe Developer, to be exact) name it's classes
and later watching him running into the problem of names clashing between
different developers naming different classes
using the same name, why not let the user take care of forgiving _universally_
_unique_ _class_ _names_? This could be achieved very easily if we adopt the
model XML uses for namespaces:

foo: make object! [
super: none
class: http://www.christian-ensel.de/classes/foo.r
...
]

bar: make object! [
super: http://www.foobar.com/classes/foo.r
class: http://www.foobar.com/classes/bar.r
...
]

This also may serve as a solution to the networking problem as well,
because everyone who wants to work with such class based objects knows
where to get the class definition.

Or am I missing something?

Regards,

Christian (Ensel :) 

 

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with unsubscribe in the 
subject, without the quotes.




[REBOL] Re: pseudo-class inheritance at a price ?

2001-10-07 Thread Christian Ensel

Hello Christian Morency,

some months ago I worked an a similiar project, you can find my code at the
bottom of this mail. It's not very complete, but it may inspire you in a way
or two :)

 As I mentioned in another post earlier, I've been working for the past three
 weeks on a pseudo class inheritance library for Rebol/Core. This would
 enable rebol developers to use class to define object or class inheritance.
 
 Why ? The current implementation of object inheritance under rebol is done
 by a way of cloning (ie copying everything) from one object to the other.
 
 Hmm and ? What I've been working on enable small objects (in term of memory
 and method code) to refer big class (with a lot of method code).

 But ? However, my implementation would require some diversions from the way
 we actually code objects in rebol ! I would like to ask to those interested
 in such a library if these diversions would be inappropriate to their coding
 style, taste, etc...

I don't believe this to be a big problem. There are other dialects in REBOL
differing from native REBOL style and syntax, e.g. the dialects used for
PARSE and VID.

And now for some comments:

 1. new class would be define like this :
   make-class 'class-name [ ... ]
 
   Inherited class would be define like this :
   make-class/from 'class-name [ ... ] super-class-name

I for a reason decided against a construct using refinements because this
would make reading your code unneccessarily hard: The specification of the
superclass as an argument to a refinement leads to code looking like

make-class/from 'class-name [
;...
;... insert hundreds of line of method code here
;...
] super-class-name

Having a special functions for deriving classes eases reading code a lot,
allowing for having 'class and 'superclass on the same line of code:

make-derived-class 'class-name 'superclass-name [
;...
;... insert hundreds of line of method code here
;...
]

What do you think?

 2. Object would be instanciated as :
   new-object-name: class-name/new
 
   I'm thinking about adding an automatic initiation method
   that would be call when instanciating an object ! What
   about a destroy method...

Actually, I haven't thought in deep about that, but as long as REBOL has it's
own garbage collector, do we really need constructors and deconstructors?

 4. Within class declaration, methods would be define like this :
   method-name: func [value !refinement ref-value] [ ... ]
 
   However, during execution, refinement would be use as usual :
   method-name a value
   mathod-name/refinement a value a ref-value

I didn't spend effort to allow for method refinements in my OOP-framework,
but IIRC there was a solution to compose function calls with refinements
on the mailing list some time ago which shouldn't be to hard to implement.

But if your refinement defining syntax differs from FUNC's style why not
rename your FUNC to METHOD, making the difference somewhat more obvious?
Just a thought, so. 

 Note : the library has not been tested enough for a public release. also, it
 would requires some testing by people working daily with objects in rebol,
 mainly rebol gurus who could tell me if everything I'm doing is proper or
 not ;) and how it could be better... or if a guru would like to take up the
 project and make it better ! I'm open to suggestion !

Not beeing a REBOL guru in any way you eventually may find some suggestions
in my code :) 

Kind regards,

Christian


;

REBOL [
title:   Classes  Instances
name:%class-instances.r
author:  Christian 'CHE' Ensel
date:23-Aug-2001
]

context
[
;=== CLASS instance-spec class-spec ==
;--
class: func
[
Defines a user class object.

instance-spec [block!] Code per instance
class-spec[block!] Code per class

/local
new-class
]
;.
[
new-class: make object! compose [
super-class: none
instance: (
make object! head insert instance-spec compose [class: none]
)
(class-spec)
]
new-class/instance/class: new-class
new-class
]
;-


;=== DERIVED-CLASS super-class instance-spec class-spec ==
 
;--
derived-class: func
[
Derives a user class object from an existing class object.

super-class   [object!] Class to inherit from
instance-spec [block!]  Code per instance
class-spec[block!]  Code per class

/local
new-class
]

[REBOL] Re: Complex Series XML Parsing?

2001-03-08 Thread Christian Ensel

Hi Terry Brownell,

on wednesday, 07-Mar-01, 23:48:09, Terry Brownell wrote on subject
"[REBOL] Complex Series XML Parsing?":

 so that we get...
 
 thexml: [
 tag1"This is some string"
 tag2"with embedded tags"
 tag1"and another"
 tag3"with this string"
 tag1"ending with this string."
 ]

The format you've choosen looks a little bit unusual to me, because
I don't see why you drop the nesting information packed into the xml
source.

However, the following quick and dirty code may at least
be a starting point ... assuming that you've only have to deal with
valid xml (no prologue, no DTD etc.), and aren't interested in comments
or processing-instructions. 

Out of your example it produces:

document: [
thexml [
tag1 [
"This is some string"
tag2 ["with embedded tags"]
"and another"
tag3 ["with this string"]
"ending with this string."
]
]
]

Regards,

Christian

--
REBOL []

xml: {
thexml
tag1This is some string tag2with embedded tags/tag2empty/
and another tag3with this string,/tag3ending with this string
/tag1
/thexml
}

container: document: []
append/only containers: [] container

content-rule: [
any [copy a string! (a: trim/lines first a if not empty? a [append
container a])
|copy a tag!(a: first a handle-tag a)
]
]
no-space: complement charset " ^M^-^/"

handle-tag: func [tag [tag!] /local name] [
parse/all tag [copy name any no-space to end]
if equal? last element #"/" [ ;empty-tag
if equal? last element #"/" [remove back tail name]
append container to-word name
return
]
if equal? first name #"/" [ ;closing tag
container: last containers: head remove back tail containers
return
]
if equal? first name #"?" [return] ;drop pi's
if equal? first name #"!" [return] ;drop comments
;opening-tags
repend container [to-word name container: copy []]
append/only containers container
]

xml: load/markup xml
parse xml content-rule
print mold document

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.




[REBOL] BUG: parse-xml exposes words 'parent and 'paroot to global context

2001-03-03 Thread Christian Ensel

Hello list,

I just noticed that 'parse-xml exposes the words 'parent and 'paroot to the
global context.

I'm not sure if this has already been addressed by someone - however, I
consider this to be a bug, therefore I cc'd this mail to [EMAIL PROTECTED]

What do you think?

Regards,

Christian Ensel

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.




[REBOL] Re: Help required for a little parsing problem

2000-11-18 Thread Christian Ensel

Hello Nigel,

 Whilst I could probably write a (long) solution I'm sure there must be an
 elegant couple of line Rebol solution - one problem is that there may be any
 number of links in the post.

I'm not sure whether it's elegant :)

At least it's a couple of lines and does the trick for multiple occurences
of [url]...[/url] brackets:

;
post: {
This is a post - Perl is good [url]http://www.perl.com[/url], Rebol
is better [url]http://www.rebol.com[/url]!
This is a post - Perl is good [url]http://www.perl.com[/url], Rebol
is better [url]http://www.rebol.com[/url]!
This is a post - Perl is good [url]http://www.perl.com[/url], Rebol
is better [url]http://www.rebol.com[/url]!
}
parse post [
any [
to "[url]" tag: 5 skip copy url to "[/url]" (
remove/part tag add length? url 11
insert tag rejoin [
{a href="} url {" target="_blank"} url {/a}
]
)
]
to end
]
;

Hope this helps,


   Christian
   [EMAIL PROTECTED]

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.




[REBOL] Re: Help required for a little parsing problem

2000-11-18 Thread Christian Ensel

Hallo Nigel,

Andrew's version is even shorter than mine, doing it by just
'change -ing instead of 'remove -ing and 'insert -ing.

Nevertheless, here's my version with additinal comments:

parse post [
any; apply the following rule 0 or more times
[
to "[url]" ; jumps to the first occurence of "[url]"
   ; we're right ahead of it now

tag:   ; remember the position in the string

5 skip ; skip 5 characters ("[url]")

copy url to "[/url]"   ; copy everthing till we encounter a
   ; string "[/url]"
   ; 'url now holds the url, but not the brackets
   
   ; all the above is the 'parse dialect

(  ; start of code (non-dialect) section

remove/part tag add length? url 11

   ; remove length? url plus additional 11
   ; chars ("[url]" = 5 + "[/url]" = 6)
   ; from the input string,
   ; counting from the position we told
   ; 'parse to remember in 'tag

insert tag rejoin [
{a href="} url {" target="_blank"} url {/a}
]
   ; composes the html-tag and inserts
   ; it at the position 'tag
   
   ; voila!

)  ; end of code section
]
to end
]

If you want to learn about 'parse see the new user guide on rebol.com,
chapter 14. Have fun!
 

   Christian
   [EMAIL PROTECTED]

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.




[REBOL] XML-processor toy. Or: RFC

2000-11-17 Thread Christian Ensel

Hello list,

looking thru the hundreds of read and unread posts to this list, XML and
REBOL's inbuild XML 'support' is mentioned at least every some days.
Someone - wasn't it Andrew? - wanted to convert XML's DTDs to REBOL's parse
rules. I must have overseen the :) which followed this idea ...

Okay. Instead of preparing for an exam, I played with XML and read about
it on w3.org. The grammar specified there inspired me to convert it to a
parse dialect, which isn't that hard as I first thought. In it's current
state it's far from being complete -  but it does some cute little things
which give a hint to what it can do some day in far future.

 xml-data: {?xml version="1.0" standalone="yes"?
!DOCTYPE test [
!ENTITY ME "Christian Ensel"
!ELEMENT che:money ANY
!ATTLIST che:money che:currency CDATA "USD"
che:amount   CDATA #REQUIRED

]
space:name
This is some text typed by ME;.
che:money  xmlns:che= "http://www.foo.bar"
che:amount   = "0.02"
che:currency = "USD"

My two cents someday?!?
element attribute="lt;1gt;" /
/che:money
/space:name}

 xml/process xml-data


This results in the following object tree, far from beeing complete,
but IMHO some very cute things work already (e.g. declaring Entities,
see the marker ^^): 

 probe xml/the-Document
make object! [
name: none
attrs: []
content: [
make object! [
name: "space:name"
attrs: []
    content: [
"^/This is some text typed by "
"Christian Ensel"
^
".^/" 
make object! [
name: "che:money"
attrs: [
make object! [
name: "xmlns:che"
value: "http://www.foo.bar"
] 
make object! [
name: "che:amount"
value: "0.02"
] 
make object! [
name: "che:currency"
value: "USD"
]
]
content: [
"^/My two cents?!?^/" 
make object! [
name: "element"
attrs: [
make object! [
name: "attribute"
value: "1"
   ^
]
]
content: []
]
"^/"
]
]
"^/"
]
]
]
]

It's fun working with  PARSE , even though I'm strongly missing some
features which would help a lot, e.g. a  NOT  keyword or the possibility
to parse a string  TO ["" | "" | "]]"]. Things like that ...

The processor recognizes tags which aren't nested correctly, but is very
strict in this - it simply stops execution.
 
I'm very busy these days, so I'll make only little steps in next days,
but I will appreciate any comments on the idea to parse. Because
I'm a little bit uncertain on some design decisions :) I'm not even sure
if processing XML is a task where REBOL is well suited for (thinking
about things like UNICODE etc.).
  
As I already said, comments, please ;)

Attached you find the most recent version. I guess in it's current state
it does some 2 or 3 % of what a XML processor should do, and the code
looks (and is, I guess) very ugly  :(

Hint: calling XML/PROCESS with the refinement /APPLY-RULES and the name
of one of the rules in the XML object (simple the word, no lit-word, no path)
allows for testing single rules.

As in

 xml/process/apply-rule {?xml?} Prolog
== true

But you'll probably end up with

== false

more often ...

As I already said, comments, please ;)
 
Regards

   Christian
   [EMAIL PROTECTED]



-- Attached file included as plaintext by Listar --
-- File: xml-processor.r

; REBOL XML-Processor ##
; 
¯¯¯
REBOL [
title:  "XML-Processor"
author: "Christian 'CHE' Ensel"
email:  [EMAIL PROTECTED]
date:   16-Nov-200

[REBOL] to-file none? Re:

2000-07-10 Thread Christian . Ensel

Hello Robert,

on 10-Jul-00 You wrote:

 How do I do this now?

Simply write Your own 'to-file :) 

Okay, this may look like:

my-to-file: func [
"Converts to file value, skipping NONEs."
value "Value to convert."
/local block val
][
either block? value [
block: copy []
foreach val reduce value [
if not none? val [append block val]
]
either equal? 0 length? block [none] [to-file block]
][
either none? value [none] [to-file value]
]
]

Behaves like original 'to-file instead of returning none for each 'none "in" value:

 my-to-file none
== none   ; instead of %none
 my-to-file ["test" none]
== %test  ; instead of %test/none
 my-to-file ["test" none "file"]
== %test/file ; instead of %test/none/file

But be aware of 

 file? my-to-file none
== false  ; instead of true 

HTH!

Regards

   Christian
   [EMAIL PROTECTED]




[REBOL] Does rebol --do print 123 for e.g. work for ya? Re:

2000-07-06 Thread Christian . Ensel

Hello [EMAIL PROTECTED]

On 06-Jul-00, You wrote:

 I am just curious if running rebol with command line parameters work for
 you? I get following error:

 REBOL --do "print 123"

works fine for 
REBOL/Core 2.3.0.1.1 22-Jun-2000  ; i.e. Amiga 68020+ version

As does DEMO disabled
REBOL/View 0.9.9.1.1 1-Jun-2000   ;-"-

Maybe You're trying /View with Demo enabled?

No time to test this by myself
(RAM Disk too full of other REBOL stuff to use GUI ;-)

Regards

   Christian
   [EMAIL PROTECTED]




[REBOL] Objects, Making-Of Re:(4)

2000-07-04 Thread Christian . Ensel

Hello [EMAIL PROTECTED],

On 04-Jul-00, You wrote:

 Your results differ from mine, I would suggest you to try once
 more...

How embarassing! The differences are because of a typo and wrong
cutting/pasteing, sorry!
 
--- Start --
 a: 0 f: func [] [a]
 o1: make object! [a: 1 g: func [] [a]] o1/g
== 1 
 o2: make object! append [a: 2 g:] [:f] o2/g
== 0
 o3: make object! append [a: 3 g:] compose/deep [first [(:f)]] o3/g
== 0
 o4: make object! append [a: 4 g:] reduce ['first reduce [:f]] o4/g
== 0
 o5: make object! append [a: 5 g:] reduce ['func first :f second :f] o5/g
== 5
 print [o1/g o2/g o3/g o4/g o5/g a]
1 5 5 5 5 0
--- End ---

That is what You get? I hope so :)

But still o2/g, o3/g, o4/g evaluates to zero before defining o5 and
to 5 after I set o5. As far as I see this can only be because of setting
a to 5 in o5's spec.
First I thought this changes 'a in the global context, but the line where I
'print [...] all values at once proves that I'm wrong here. 

Maybe it's just that trying to understand objects, contexts, binding all at
once is to heavy for me. Maybe here the lesser is the more ...

But, each time I believe having understood something, I walk into another trap.
Like this one:

-- Start --
 o: make object! [a: 5]
 protect in o 'a
 set in o 'a 6
** Script Error: Word a is protected, cannot modify.
** Where: set in o 'a 6
 o/a: 6
== 6
-- End --

Why does the path notation doesn't throw the above error, too? 

 Regarding universality/contexts. You can try a mixed approach:
 
append spec either function? :f reduce [
 ['func third :f second :f]
] [
 ['first reduce [:f]]
]
 
 Ladislav

I decided to use ecactly this code after having slept over what I'm learned
from you! Despite of the above mentioned problems, that works fine now!


Regards
 
   Christian
   [EMAIL PROTECTED]




[REBOL] Objects, Making-Of Re:(6)

2000-07-04 Thread Christian . Ensel

Hello [EMAIL PROTECTED],

On 04-Jul-00, You wrote:

 The explanation #2:
[...]
 , but Source then created a bit different representation of that.

Oh, I like this explanation.

I already learned that 'source doesn't always show the excact source
code which was assigned to a word (e.g. a: make integer! 1).
So, for make function! it just replaces this with a, let's say, string "func"
for displaying purposes, which has nothing to do with the defined word 'func.

I always thought that *func* enhances *make function!* with the possibility to
add optional help strings, */local* words and the *[catch]* and *[throw]*
special function attributes.
This was because in the past I only saw them in conjunction with 'func when I
viewed source code with 'source.

How wrong I am!
As I see now, I can all this do with *make function!*, too.
(You for example did this for Your 'cfor in %highfun.r, I just looked it up).

But if this is true, I can see only one reason why *func* is a pre-defined
word (if I don't take into account that *func* is 10 chars shorter than
*make function!*):

Beginners like me can do *help func*, but they can't do *help make function!*.
Nothing more, nothing less.

Or am I wrong again? :)

Regards
 
   Christian
   [EMAIL PROTECTED]

   - Who already learned a lot from this thread, 
 even if it's name doesn't suit very well




[REBOL] Objects, Making-Of

2000-07-03 Thread Christian . Ensel

Hi Rebols,

while playing around with objects, I trapped into this:

 f: func [] [print "Hello!"]
 f
Hello!
 spec: []
== []
 append spec to-set-word 'attribute
== [attribute:]
 append spec 5
== [attribute: 5]
 append spec to-set-word 'function
== [attribute: 5 function:]
 append spec :f
== [attribute: 5 function: func [][print "Hello!"]]

Okay, looks like I'm now having an appropriate specification block for
making an object, but:

 probe object: make object! spec
Hello!
** Script Error: function needs a value.
** Where: function: func [][print "Hello!"]

What's this? Shouldn't the above return something like

make object! [
attribute: 5
function: func [][print "Hello!"]
]

The same error occurs if I'm printing spec:

 print spec
Hello!
** Script Error: function needs a value.
** Where: function: func [][print "Hello!"]

where one would expect

5 ?function?

I'm guessing that the error occurs because of wrong contexts of the words in
the spec block. Am I right? And what am I doing wrong here?

Even studying the Rebol.org threads on Contexts and Rebol internals  implementation 
(recently mentioned on the list) gave me no idea ...

Christian
[EMAIL PROTECTED]




[REBOL] Objects, Making-Of Re:(2)

2000-07-03 Thread Christian . Ensel

Hi Ladislav,

 1) you shouldn't redefine Function (a Rebol mezzanine), but that
 didn't cause your trouble

This was just to use speaking names for the example :) 

 2) the problem has nothing in common with contexts.

Obviously I'm still not able to assume correctly where my problems with Rebol
are located ...
 
 instead try eg. append spec reduce ['first reduce [:f]]

Thanks! 
That surely did it - even I still don't fully understand the problem.
Looks as if I were trying to append the function itself instead of just
it's source code (spec and body).

BTW, meanwhile I found that

 append spec reduce ['func first :f second :f]

works, too. I once knew about that, but thought there should be a more direct
approach. Like Yours.
 
Regards

Christian
[EMAIL PROTECTED]




[REBOL] Objects, Making-Of Re:(2)

2000-07-03 Thread Christian . Ensel

Hello [EMAIL PROTECTED]!

On 03-Jul-00, You wrote: 

[...]
 The two blocks look the same, but they aren't.
[...]

That's what was irritating me ...


But now the context thing comes in for real, ;-)
Look at the following console session 

-- Start of console session --
 a: 0 f: func [] [a]
 o1: make object! [a: 1 g: func [] [a]] o1/g
== 0
 o2: make object! append [a: 2 g:] [:f] o2/g
== 0
 o3: make object! append [a: 3 g:] compose/deep [first [(:f)]] o3/g
== 0
 o4: make object! append [a: 4 g:] reduce ['first reduce [:f]] o4/g
== 0
 o5: make object! append [a: 5 g:] reduce ['func first :f second :f] o5/g
== 5
 o1/g o2/g o3/g o4/g o5/g a
1
5
5
5
5
0
-- End of console session --

o1 is okay, anyway.
The making of o3 and o4 are equivalent IMHO (o3 are Gabriele's idea, o4 Ladislav's).
o5 is my own approach, it keeps care of contexts, but - as Ladislav pointed out - 
doesn't work for
native!s and action!s.

Any idea on how an o6 can be done, which preserves context *and* works for
native!s and action!s?

And finally, why do I get that strange 1 5 5 5 5 0 results? How does o2 to o4
know about o5's a: 5? Lots of homework to do ... 

Regards

   Christian
   [EMAIL PROTECTED]




[REBOL] Objects, Making-Of Re:(4)

2000-07-03 Thread Christian . Ensel

Hello [EMAIL PROTECTED],

On 03-Jul-00 You wrote:

[...] 
 Your approach should preferrably be:

append spec reduce ['func third :f second :f]
[...]  ^

This one will suit my needs, I think. 
third :f is even better than first :f, of course!
Thank You very much!

But now I'm wondering if there's a way to universally create
objects by assembling a spec block as I did, appending any-function!s
AND taking care of contexts. 

Finally, another question, closely related, arised in this process:

I never understood why

-- start of console session --
 source func
*func*: *func* [
"Defines a user function with given spec and body." [catch] 
spec [block!] {Help string (opt) followed by arg words (and opt type and string)} 
body [block!] "The body block of the function"
][
throw-on-error [make function! spec body]
]
 source throw-on-error
throw-on-error: *func* [blk][
if error? blk: try blk [throw blk] 
:blk
]
-- end of console session --

doesn't leed to endless recursion. 

Thanks again,
Regards

   Christian
   [EMAIL PROTECTED]