[REBOL] One function per class Re:(11)

2000-06-06 Thread Galt_Barber




Joseph, I'm busting a gut here!
(If only we'd had a monkey...)





[REBOL] One function per class Re:(10)

2000-06-06 Thread jkehoe

>> > YOU had cassette tapes?  Well, you sure had it easy!
>> >
>> > Why, we used to lie awake at night, DREAMIN o' cassette tapes!
>> 
>> So, you remember storing programs on punched paper tape, then?
>
>you mean you had a paper tape machine?...wow! We used to have to
>store our source code with paper and pencil...;^)

Once programmed a PDP-8 (pre-punch cards) input via a set of 12(?) on/off switches 
output on 16(?) LED's. When not in use it was used as a heater (no, I'm not kidding)!

Of course in them days we worked 25 hours a day getting up 3 hours before we went to 
bed and lived on a diet of rotten cardboard.  We were only allowed access to the 
machine through second class post to a wild monkey who flicked the switches with his 
one good tail in a darkened room.  Of course we were a lot happier back then.
Tell that to the youth of today though ;-)
--
Joseph Kehoe, MSc
Raven Internet Technologies Ltd.
ph: +353 503 52450
www.raven.ie




[REBOL] One function per class Re:(9)

2000-06-05 Thread Galt_Barber




>> >> >I wrote something in BASIC a long way back on an Australian copy of a
Tandy
>> >> >computer, that played tones when I struck keys on the keyboard.
>> >> I guess that Dates Andrew also
>> >> :>) -Tim

>> >Way back, in the time of yore, when real computer programmers used magnetic
>> >cards or cassette tapes to hold programs...
>> >
>> >And cursed when they didn't work. :-)
>> >
>> >Andrew Martin

>> YOU had cassette tapes?  Well, you sure had it easy!
>>
>> Why, we used to lie awake at night, DREAMIN o' cassette tapes!
>>
>> -galt
>
>So, you remember storing programs on punched paper tape, then?
>
>- Michael Jelinek

Yup, I got a beautiful paper-tape punch a-rusting away at home right now!

Hey, Carl, when is Rebol/Command going to support the UBSKYOO/R paper tape API ?
I got some old assembler routines on paper tape I was planning to use with
Rebol.


-

Did anybody look at the /View viewer.r program I posted recently?
Why does the text field freak out after pressing the jump button
so that I have to switch the focus away and back before it wakes up again?
Am I doing something wrong?

-

-galt






[REBOL] One function per class Re:(9)

2000-06-05 Thread alans

[Charset iso-8859-1 unsupported, filtering to ASCII...]
> > >> >I wrote something in BASIC a long way back on an Australian copy of a
> Tandy
> > >> >computer, that played tones when I struck keys on the keyboard.
> > >> I guess that Dates Andrew also
> > >> :>) -Tim
> 
> > >Way back, in the time of yore, when real computer programmers used
> magnetic
> > >cards or cassette tapes to hold programs...
> > >
> > >And cursed when they didn't work. :-)
> > >
> > >Andrew Martin
> 
> > YOU had cassette tapes?  Well, you sure had it easy!
> >
> > Why, we used to lie awake at night, DREAMIN o' cassette tapes!
> 
> So, you remember storing programs on punched paper tape, then?

you mean you had a paper tape machine?...wow! We used to have to
store our source code with paper and pencil...;^)

> 
> - Michael Jelinek
> 

--Alan
<[EMAIL PROTECTED]>




[REBOL] One function per class Re:(8)

2000-06-05 Thread mjelinek

> >> >I wrote something in BASIC a long way back on an Australian copy of a
Tandy
> >> >computer, that played tones when I struck keys on the keyboard.
> >> I guess that Dates Andrew also
> >> :>) -Tim

> >Way back, in the time of yore, when real computer programmers used
magnetic
> >cards or cassette tapes to hold programs...
> >
> >And cursed when they didn't work. :-)
> >
> >Andrew Martin

> YOU had cassette tapes?  Well, you sure had it easy!
>
> Why, we used to lie awake at night, DREAMIN o' cassette tapes!

So, you remember storing programs on punched paper tape, then?

- Michael Jelinek




[REBOL] One function per class Re:(7)

2000-06-05 Thread Galt_Barber




>> >I wrote something in BASIC a long way back on an Australian copy of a Tandy
>> >computer, that played tones when I struck keys on the keyboard.
>> I guess that Dates Andrew also
>> :>) -Tim

>Way back, in the time of yore, when real computer programmers used magnetic
>cards or cassette tapes to hold programs...
>
>And cursed when they didn't work. :-)
>
>Andrew Martin

YOU had cassette tapes?  Well, you sure had it easy!

Why, we used to lie awake at night, DREAMIN o' cassette tapes!

-galt






[REBOL] One function per class Re:(6)

2000-06-04 Thread Al . Bri

> >I wrote something in BASIC a long way back on an Australian copy of a
Tandy
> >computer, that played tones when I struck keys on the keyboard.
> I guess that Dates Andrew also
> :>) -Tim

Way back, in the time of yore, when real computer programmers used magnetic
cards or cassette tapes to hold programs...

And cursed when they didn't work. :-)

Andrew Martin
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
-><-




[REBOL] One function per class Re:(5)

2000-06-03 Thread tim


>> >Swaine in DDJ once mentioned that programmers have a high correlation
>with musicians. I wonder how much of a correlation there is with REBOL
>scripters and musicians there are on this list?
>
>> I really connected with "C" with I found out that I could set the PC
>speaker (8086 in 1989) to Concert "A" (440 hz). I then deduced the
>mathematical relationships (an octave is a factor of 2, 1.0594 defines a
>half-step), derived all scales, key, and modes from that and wrote a program
>that played an arrangement of Mussorgsky's Three Pictures at an
>Exhibition the rest is history. Wonder if I could translate Dylan into
>Rebol? Guess that dates me.
>
>I wrote something in BASIC a long way back on an Australian copy of a Tandy
>computer, that played tones when I struck keys on the keyboard.
I guess that Dates Andrew also
:>) -Tim

>Which leads one into wondering, can we play music _with_ rebol yet? :-)
>Rebol/Command yes (I think). The other rebols? Probably not?
>
>Andrew Martin
>Art/Science
>ICQ: 26227169
>http://members.xoom.com/AndrewMartin/
>-><-
>
>




[REBOL] One function per class Re:(4)

2000-06-03 Thread anton

[EMAIL PROTECTED] wrote:

> Nazdarek [EMAIL PROTECTED]
>
> On 02-çen-00, [EMAIL PROTECTED] wrote:
> > galt wrote:
> >> Andrew, you play the fiddle?  I didn't know that!
> >> I love playing the fiddle, too!  (although I seem
> >> to spend more time playing with Rebol these days...)
> >
> > Sorry, I meant fiddling as in playing or fooling around in REBOL.
> >
> > :-)
> >
> > Swaine in DDJ once mentioned that programmers have a high correlation with
> > musicians. I wonder how much of a correlation there is with REBOL scripters
> > and musicians there are on this list?

I play violin (a bit too violently - I broke my bow on Paganini recently) and used
to love composing stuff in Octamed.

> Since 90s when I bought an Amiga and found Protracker2.3 (or was it ver
> 1.something? doesn't matter anyway...) I'm still trying and now I am member of
> two local bands ( WEIRDDREAM - www.volny.cz/weirrdream and BULLERBYNE -
> bullerbyne.musichall.cz (not sure with this - we STRONGLY need to update our
> pages)) and I co-organized some parties in two or three clubs here in Brno,CZ.
> With Bullerbyne we played in 1998 on JAM festival in Prague with Bjork, Banco
> de Gaia, Apocalyptica...
> Now sound interests me more than music and I'am trying to write modullar
> synthesizer for REBOL. Partial results can be found on sintezar.bizland.com .

It looks interesting. You seem to be on the right track. I'm glad I'm not the only
one to think of this use for rebol! (Trying to dowload it now... Oh yes, it makes
a sound! Took 3 seconds using the pc at work...)
I had a lot of ideas in this area. Rebol seems such a great language to use.

For example, I wanted to make a kind of tracker where all the different columns of
data are fully separable. We shouldn't be limited to fixed block sizes and rigidly
aligned tracks.
Also, we should be able to use the results of a track as a sample, inserting it as
many times as we want, and optionally applying different effects each time. This
should be a recursive technique, meaning that we should be able to embed tracks
within tracks within tracks... With lots of caching, this can be done.

Then there is the issue of control. With one slider we should be able to do many
interesting things at once. For example, given a series of volumes:

myvolumes: [1 1 1 1]

we should be able to program a slider so that it alters any combination of these
values.
If we link it so that it alters the third a fourth value, when we move the slider
down, we should get for an instant [1 1 0.5 0.5].

myvolumes may be used in a song at many places. Because it has been embedded in
several tracks, when the playing position gets to a point where myvolumes is used,
the latest updated values are used to compute the track volume.

But, because it's just a series, it needn't necessarily be used only to specify
volume... eg. cutoff, resonance.
And the same slider action could also control something like the octave of an
instrument, etc etc ad inifiinitum.

I need a dialect for all these specifications. Rebol has gone halfway already. I
need to do the other half. Do I sound like a madman? I know it can work! A tracker
in rebol might be a bit slow, though... but for dialecting and testing it will be
great.

I need some feedback from people. I don't think I can do it on my own anymore.
It's too big!
Save me from my frustration and madness! ;-)

Anton.




[REBOL] One function per class Re:(3)

2000-06-01 Thread allenk

>
> Sorry, I meant fiddling as in playing or fooling around in REBOL.
>
> :-)
>
> Swaine in DDJ once mentioned that programmers have a high correlation with
> musicians. I wonder how much of a correlation there is with REBOL
scripters
> and musicians there are on this list?
>
> Andrew Martin
> ICQ: 26227169
> http://members.xoom.com/AndrewMartin/

Interesting Andrew.

I organised parts of the National Campus Band Competition finals here in
1995, and have plenty of muso friends (one just signed an international deal
with Warner). And I can't work without listening to music. So I think the
theory holds true :-)

Oh and because I come from Brisbane I do know someone who knows the guys
from Savage Garden. (And you can find my name in the thank you credits of a
number of albums by various Aus artists. Happy by Real Life for one.)

Cheers,

Allen K

I can't play an instrument but I can blow my own horn sometimes...





[REBOL] One function per class Re:(4)

2000-06-01 Thread Al . Bri


> >Swaine in DDJ once mentioned that programmers have a high correlation
with musicians. I wonder how much of a correlation there is with REBOL
scripters and musicians there are on this list?

> I really connected with "C" with I found out that I could set the PC
speaker (8086 in 1989) to Concert "A" (440 hz). I then deduced the
mathematical relationships (an octave is a factor of 2, 1.0594 defines a
half-step), derived all scales, key, and modes from that and wrote a program
that played an arrangement of Mussorgsky's Three Pictures at an
Exhibition the rest is history. Wonder if I could translate Dylan into
Rebol? Guess that dates me.

I wrote something in BASIC a long way back on an Australian copy of a Tandy
computer, that played tones when I struck keys on the keyboard.

Which leads one into wondering, can we play music _with_ rebol yet? :-)
Rebol/Command yes (I think). The other rebols? Probably not?

Andrew Martin
Art/Science
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
-><-




[REBOL] One function per class Re:(3)

2000-06-01 Thread tim

Here's one for you Andrew:
>Swaine in DDJ once mentioned that programmers have a high correlation with
>musicians. I wonder how much of a correlation there is with REBOL scripters
>and musicians there are on this list?
I really connected with "C" with I found out that I could
set the PC speaker (8086 in 1989) to Concert "A" (440 hz).
I then deduced the mathematical relationships (an octave is
a factor of 2, 1.0594 defines a half-step), derived all
scales, key, and modes from that and wrote a program that
played an arrangement of Mussorgsky's Three Pictures at
an Exhibition the rest is history. Wonder if I could
translate Dylan into Rebol? Guess that dates me.
:) Tim
>Andrew Martin
>ICQ: 26227169
>http://members.xoom.com/AndrewMartin/
>-><-
>
>




[REBOL] One function per class Re:(2)

2000-06-01 Thread Al . Bri

galt wrote:
> Andrew, you play the fiddle?  I didn't know that!
> I love playing the fiddle, too!  (although I seem
> to spend more time playing with Rebol these days...)

Sorry, I meant fiddling as in playing or fooling around in REBOL.

:-)

Swaine in DDJ once mentioned that programmers have a high correlation with
musicians. I wonder how much of a correlation there is with REBOL scripters
and musicians there are on this list?

Andrew Martin
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
-><-




[REBOL] One function per class Re:

2000-06-01 Thread Galt_Barber




Andrew, you play the fiddle?  I didn't know that!
I love playing the fiddle, too!  (although I seem
to spend more time playing with Rebol these days...)

-galt





[REBOL] One function per class Re:

2000-06-01 Thread agem


think again about your original style:
objects calling "global" functions.
you are on special prototype-oops here.
the way "one class per object" is very cool,
for me i have a base-class with a 'save -func in,
and if i want to change the 'save -behavior i simply
change the function (bit binding or obj: make obj[..]).
sometimes i use specialised functions 
with the filename inlined or that.

ok, if i save this object, i never want to have the "latest"
function. and if you look a bit at javas serialisation
and programmers effort to stay compatible to an older class-version :(

on the other hand, if i define
  save-really: func[a][prin[t "i save" mold a]]
  save-never: func["read-only" a][print ["i save not:)" mold a]]
  a: make object![ save: func[][save-really self]] 
  b: make object![ save: func[][print "hey! they save me!" save-really self]] 

i have: 
 individualism if needed, 
 small object, 
 a clean definition of the objects behavior 
  (old objects calls old global 'save, changed 'save gets new name)
not perfect in a big programm,
but with the usual some handfulls of rebol is quite handy.

note too the rebol-way of 'ports :
global functions call some specialiced object-functions in a standart
way. a global read calls an object's 'open', read-io, 'close .
(i think. or is a 'read too defined in a 'port ? at least this
way can work?)
i use a global 'save-t which formats the text-object if its
a rebol-file, then calls the personal 'save . is handy.
(if i think the object should format itself,
i can ask if it knows this new function, else call the old default.
or, easier, simply load the database and add it everywhere,
if not too distributed :)

so i define global functions which "asks" the object to do 
special things. the object knows some short control-code,
which call the right global functions to do the service.
short objects, individual behavior, safe extending.

note this is the usual way a os-windows is handled
(know all this switch WM_ -stuff? size of this? need of knowledge?)
which is the most complex part of a usual program.
how easy is this way of "messaging" written in rebol!



> Michael Jelinek wrote (in refinements thread):
> > I really just want to separate the definition of the method (function
> body) from the object, but I still want the method to be called as part of
> the object. Some of these objects can be saved to a file and reloaded, and I
> want the function "bound" to the latest definition in the program, not what
> the definition was at the time that the object was saved. Also, although I
> can't claim to "know" the internals of REBOL, I don't want multiple copies
> (or worse, definitions) of the function floating around - it's inefficient.
> 
> This is the core of the problem. To have one function per "class" of object,
> not one function per instance, for REBOL. This is easily done in C++, not so
> easily in REBOL. I'm sure it can be done with some suitably cunning script.
> 
> I'll have to think about it more deeply, after I've done some fiddling.
> 
> Andrew Martin
> OO Rebol...
> ICQ: 26227169
> http://members.xoom.com/AndrewMartin/
> -><-
> 
> 
> 




[REBOL] One function per class Re:

2000-06-01 Thread brian . hawley

Andrew Martin wrote:
>Michael Jelinek wrote (in refinements thread):
> > I really just want to separate the definition of the method (function
>body) from the object, but I still want the method to be called as part of
>the object. Some of these objects can be saved to a file and reloaded, and I
>want the function "bound" to the latest definition in the program, not what
>the definition was at the time that the object was saved. Also, although I
>can't claim to "know" the internals of REBOL, I don't want multiple copies
>(or worse, definitions) of the function floating around - it's inefficient.
>
>This is the core of the problem. To have one function per "class" of object,
>not one function per instance, for REBOL. This is easily done in C++, not so
>easily in REBOL. I'm sure it can be done with some suitably cunning script.
>
>I'll have to think about it more deeply, after I've done some fiddling.

Why don't you do what other unique-object OOP languages do,
use class factory objects? Like this:

Accounts: make object! [
 total-balance: $0  ; Class variable
 new: func [/init bal [number! money!] /local the-class] [
 the-class: self
 bal: to-money any [bal $0]
 total-balance: total-balance + bal
 make object! [
 class: the-class
 balance: bal
 deposit: func [amount [number! money!]] [
 class/deposit self amount
 ]
 withdraw: func [amount [number! money!]] [
 class/withdraw self amount
 ]
 transfer: func [
 account [object!] amount [number! money!]
 ] [class/transfer self account amount]
 close: func [] [class/close self]
 ]
 ]
 deposit: func [account [object!] amount [number! money!]] [
 account/balance: account/balance + amount
 total-balance: total-balance + amount
 amount
 ]
 withdraw: func [account [object!] amount [number! money!]] [
 account/balance: account/balance - amount
 total-balance: total-balance - amount
 amount
 ]
 transfer: func [
 account [object!] account2 [object!] amount [number! money!]
 ] [
 account/balance: account/balance - amount
 account2/balance: account2/balance + amount
 amount
 ]
 close: func [account [object!]] [
 total-balance: total-balance - account/balance
 account/balance: $0
 ]
]

Although OOP is overkill for this example, this does show a design
pattern that I have found useful for other tasks, such as parsing with
side effects. The XML parser could use this pattern, for example.

The trick that you should realize in REBOL is that OOP, while supported,
is rarely the best approach. The objects in REBOL have context overhead
that make them rather memory-intensive. It's more appropriate to use OOP
when you have a few large objects. Small objects are better represented
with simpler structures like blocks.

Remember, the idea that OOP requires classes is just held by class-based
OOP language people. The OOP community at large is much more flexible,
including OOP languages built around delegation, actors, closures, etc.
REBOL is much better at following the delegation or closure patterns
than it is at classes (you need concurrency to do the actor pattern).

I hope this helps...

Brian Hawley




[REBOL] One function per class Re:(4)

2000-06-01 Thread lmecir

As this originally was Refinements, it needed some fiddling:

; method creator
meth: func [
{defines a user method with given spec and body}
spec [block!]
body [block!]
] [
; use copies of the original spec and body blocks
spec: copy spec
body: copy/deep body
; find the right place to insert the Self specification
while [
all [
not tail? spec
any [string? first spec block? first spec]
]
] [spec: next spec]
; insert the Self specification
insert spec copy/deep [self [object!]]
func head spec compose/deep [
do bind/copy [(body)] in self 'self
]
]

; method calling dialect:

!: func [
{method caller}
[catch]
message [block!] {
The structure of a message is as follows:

method-path
object
additional arguments according to the method spec
}
/local method-path method-name self position cls
] [
if not (length? message) > 1 [
throw make error! {invalid message}
]
if not any [
word? set/any 'method-path first message
path? get/any 'method-path
] [
throw make error!
{invalid method - must be a word or a path}
]
if not path? :method-path [
method-path: to path! method-path
]
method-name: first :method-path
position: next message
set/any [self position] do/next position
if not object? get/any 'self [
throw make error! {self is not an object}
]
if not cls: in self 'class [
throw make error! {incompatible object}
]
if not object? set/any 'cls get/any get cls [
throw make error! {incompatible class}
]
if not method-name: in cls method-name [
throw make error! {no such method}
]
change :method-path method-name
do compose [(:method-path) (self) (position)]
]

; sample class, feel free to change it as you please:

sample-class: make object! [
; a method returning the object type
type: meth [] [
class
]
; a static value - counter
counter: 0
; a counting method
count: meth [] [
counter: counter + 1
]
reftest: meth [/ref] [
either ref [
print "Ref"
] [
print "No ref"
   ]
]
]

; sample objects of a sample-class

sample-object1: make object! [
class: 'sample-class
number: ! [count self]
]

sample-object2: make sample-object [
number: ! [count self]
]

; sample method calls
! [type sample-object1]
! [type sample-object2]
! [nonsense sample-object1]
! [reftest sample-object2]
! [reftest/ref sample-object2]





[REBOL] One function per class Re:(3)

2000-06-01 Thread lmecir

Hi,


> Ladislav wrote:
> > the solution was presented here some time ago. Can repost it.
>
> I must have missed it. Please do so.
>
> Thanks!
>
> Andrew Martin
> Full of curiosity...
> ICQ: 26227169
> http://members.xoom.com/AndrewMartin/
> -><-

I decided to enhance it a bit...

; method creator
meth: func [
{defines a user method with given spec and body}
spec [block!]
body [block!]
] [
; use copies of the original spec and body blocks
spec: copy spec
body: copy/deep body
; find the right place to insert the Self specification
while [
all [
not tail? spec
any [string? first spec block?first spec]
]
] [spec: next spec]
; insert the Self specification
insert spec copy/deep [self [object!]]
func head spec compose/deep [
do bind/copy [(body)] in self 'self
]
]

; method calling dialect:

!: func [
{method caller}
[catch]
message [block!] {
The structure of a message is as follows:

method-name
object
additional arguments according to the method spec
}
/local method-name self position method
] [
set/any [method-name position] do/next message
if not word? get/any 'method-name [
throw make error! {method name is not a word}
]
set/any [self position] do/next position
if not object? get/any 'self [
throw make error! {self is not an object}
]
if not method: in get self/class method-name [
throw make error! {no such method}
]
do compose [(method) (self) (position)]
]

; sample class, feel free to change it as you please:

sample-class: make object! [
; a method returning the object type
type: meth [] [
class
]
; a static value - counter
counter: 0
; a counting method
count: meth [] [
counter: counter + 1
]
]

; sample objects of a sample-class

sample-object1: make object! [
class: 'sample-class
number: ! ['count self]
]

sample-object2: make sample-object [
number: ! ['count self]
]

; sample method calls
! ['type sample-object1]
! ['type sample-object2]
! ['nonsense sample-object1]




[REBOL] One function per class Re:(2)

2000-06-01 Thread Al . Bri

Ladislav wrote:
> the solution was presented here some time ago. Can repost it.

I must have missed it. Please do so.

Thanks!

Andrew Martin
Full of curiosity...
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
-><-




[REBOL] One function per class Re:

2000-05-31 Thread lmecir


- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 01, 2000 6:57 AM
Subject: [REBOL] One function per class


> Michael Jelinek wrote (in refinements thread):
> > I really just want to separate the definition of the method
(function
> body) from the object, but I still want the method to be called
as part of
> the object. Some of these objects can be saved to a file and
reloaded, and I
> want the function "bound" to the latest definition in the
program, not what
> the definition was at the time that the object was saved. Also,
although I
> can't claim to "know" the internals of REBOL, I don't want
multiple copies
> (or worse, definitions) of the function floating around - it's
inefficient.
>
> This is the core of the problem. To have one function per
"class" of object,
> not one function per instance, for REBOL. This is easily done in
C++, not so
> easily in REBOL. I'm sure it can be done with some suitably
cunning script.
>
> I'll have to think about it more deeply, after I've done some
fiddling.
>
> Andrew Martin
> OO Rebol...
> ICQ: 26227169
> http://members.xoom.com/AndrewMartin/
> -><-
>

Hi,

the solution was presented here some time ago. Can repost it.

Regards
Ladislav