[REBOL] Re: Enhancement Request - /Integer and /Fraction Refinements for integers and decimals

2000-10-22 Thread Christian Ensel

Hello Andrew,

> And the equivalent for money! could be called /Dollars and /Cents.

Isn't this a bit america-centristric? I'd prefer /Mark and /Pfennig,
or /Euro and /Cent.
And Gabriele would probably prefer /Lira.
Just joking ...


Christian
[EMAIL PROTECTED]

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




[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:(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 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:(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]




[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:(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

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]