Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Looking over the horizon - Rebol 3

From: didec:tiscali at: 10-Nov-2003 16:17

Re: Re: Looking over the horizon - Rebol 3 (See at bottom)
> Hi, Andrew, > > Thanks for starting what I hope will be a productive thread! Now, > speaking strictly for myself, little of my REBOL wish list is about > adding features to the language. > > Andrew Martin wrote: > > > > * Lots more datatypes! For example, a Telephone! data type, temperature, > > audio/sound data-type, metric and imperial units like 123.5Km, 50MpH, > > and so on... > > > > No. Please, no. Please, please, no. > > There have been plenty of threads in the past about the confusing and > not-completely-documented behavior associated with the existing plethora > of types. Do we really want that situation compounded??? (e.g. what > happens when I add 2 to 123.5Km, what happens when I multiply 50MpH by > 32F, ...) > > I realy have only two wishes in regard to data types: > > 1) Fully document the existing ones. > 2) Add support for promoting objects to true user-defined types. > > I hope the first is obvious (and non-controversial) to the list. > > Let me give a trivial example of the second issue, and then apply it > (in a non-trivial way, I hope! ;-) to your wish list above. > > REBOL has a PAIR! type which can be used for 2D points, but suppose I > am working on projective geometry in a serious way. I can define > > ; projective point > > ppoint: make object! [ > u: v: w: 0 ; projective coordinates of pline > to-string: func [] [...] ; create a printable representation > ... ; other natural behavior of a ppoint > ] > > ; projective line > > pline : make object! [ > p: q: r: 0 ; projective coordinates of pline > to-string: func [] [...] ; create a printable representation > ... ; other natural behavior of a pline > ] > > after which I can sprinkle such things as the following thru my code: > > P1: make ppoint [u: -1 v: 2 w: 1] > P2: make ppoint [u: 4 v: 5 w: -1] > L1: make pline [p: 1 q: -1 r: 0] > > but the list of useful things I *can't* do includes the following: > > ; function that returns the point where two lines intersect > common-point: func [l1 [pline] l2 [pline]] [ > ... > ] > > ; function that returns the line joining two points > common-line: func [p1 [ppoint] p2 [ppoint]] [ > ... > ] > > ; is the given point on the given line? > pt-on-line?: func [p1 [ppoint] l1 [pline]] [ > ... > ] > > print ["line 2 is " common-line P1 P2] ; and get meaningful output > > P3: 2 * P1 ; by defining for REBOL what it means to multiply > ; a ppoint by a number > > If I want to define a function that takes a ppoint as an argument, I > can only say: > > some-function: func [ppt [object!] ...] [...] > > but then REBOL will allow *any* object to be passed (likely giving me > a run-time error when I try to actually perform some operation on/with > it inside the function body). > > Now, let's apply this idea to your list; many of your desired types > are just numbers with an associated dimensionality -- so many degrees F > (or C or K ...), yea many pounds (or grams or kilograms or stone ...), > and (with composite dimensions) thus many grams per cubic centimeter > (or miles per hour, or liters per second ...) > > If we had true type support for objects, we (*any* REBOL programmer > with enough experience/determination) could write something like > (I'm making this up as an illustration, so it's not debugged! ;-) > > dimensions: make object! [ > numerators: [] > denominators: [] > to-string: func [] [...] > ... > ] > > dimensioned-number: make object! [ > value: 0 > units: make dimensions [] > to-string: func [] [...] > ... > ] > > distance: dimensioned-number 6 [mile] > how-long: dimensioned-number .1 [hour] > print distance / how-long ; or print divide distance how-long > > and get > > 60 mile per hour > > Then someone who wanted to compute earth's escape velocity in > furlongs per fortnight could do so without further support from RT! >
As a guy who doesn't know how are implement, and more than that, how the programer use the concept of OO in any other langage (operator overload (my french->english translation)...), I can extend a litle the Joel idea like this : ppoint!: make datatype! [ u: v: w: 0 ; projective coordinates of pline add: func [p1 [ppoint!] p2 [ppoint!]] [ (stuff to add 2 ppoint values) ] substract: func [p1 [ppoint!] p2 [ppoint!]] [ (stuff to substract 2 ppoint values) ] multiply: func [p1 [ppoint!] p2 [ppoint!]] [ (stuff to multiply 2 ppoint values) ] to-string: func [] [...] ; create a printable representation ... ; other natural behavior of a ppoint ] This will create a new user datatype! with what function overload you want. It seems to me that it's easier to define the postfixed function instead of the prefixe one ('add instead of '+ ...) but not an expert ;) So the interpreter can used the user 'add function if the parameters datatype! belong to a user define one. Appart of this, I just want for the future Rebol : - Known Bug correction or workaround for : * Network Protocols * Modale window and Event filtering * To-integer (with decimal value) - Enhancement to the existing VID styles to handle current usage : * Full text-list with slider management. * Area link with a slider. * Or functions to link slider with text scroll or offset scroll (and the opposite). * Known bugs correction (text editing...). - External new VID styles features : * Just thinking of a %styles/ directory in the %desktop/ one where could be store advanced styles (treeview...) working as a cache of styles. An automatic fetching function try to download them from RT site through this directory when user use it. It's a workaround for the "Interpreter will become too big" problem, but allow extension. - Integrated async protocol - Freeing some features or make them usable : * Sound (it's already OK) * Shell access * Big number And of course - Full, or at least, better documentation (How VID works...) - Mac OS X version And last, to be able to said again that Rebol is portable : - All core and View release at the same level on all system. I probably forget something, but I let you complete ;) DideC