dotgnu-visionaries
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Visionaries] Re: WebScheme


From: Peter Minten
Subject: [Visionaries] Re: WebScheme
Date: Wed, 07 May 2003 19:06:18 +0200

Guess what? :-)

The (return) function has a rather irritating consequence when used within a
looping structure. Since loops are implemented using tail-call-recursion
(return) in a loop effectively exits the loop and not the function the loop is
in. This problem is unsolvable without messing up the language, but it can be
worked around. I'm now defining
that every Procedure object has a private method 'escape' that is, like all
private fields of procedures, accessible from within the procedure. The (return)
function is now an alias for (this.escape). By using something like (define foo
this.escape) it's possible to exit a function that is not the lowest level
function (well, it automatically exits the lower functions too).

A nice little trick that's possible with the dot operator is defining functions
like (obj.>) and (obj.==). This is perfectly valid, and in some cases improves
readability. The following guidelines regulate the use of this trick in the
official libs:
* Stream operators are object functions ((obj.<<),(obj.>>))
* Comparision operators are generic functions ((>=),(==))
* Mathematical operators are generic functions ((+), (*))

As said before all fields have accessors. The introduction of r-data and refs
have changed the syntax of these however. The get accessor of a field f is now
called (^f.get) and the set accessor (^f.set value).

An often occuring problem is invoking a method of an object that is returned by
a function. This is done using (invoke obj member . args), for example (invoke
(car '("Foo", "Bar")) 'size) which returns 3 (length of "Foo" is 3). The member
name must be quoted since it's not a variable name. The following macro
expansion is done:
(invoke obj member . args) -> ((get-field obj member) args).

WebScheme will support regular expressions. The style of regular expressions is
libc. Regular expressions can be specified using #r/regex/ or (Regex.new
regex-string), thus #r/[a-zA-Z]+/ matches every string of one or more letters.
Regular expressions are matched using (regexobj.match string-to-match), thus the
following would be good (#r/[a-zA-Z]+/.match "DotGNU"). The result of a regex
match is either #f in case of a no match or an object of class RegexMatch which
contains information about the match (for example what part matched).

Implementation rule: implementations are required to make it seem to the outside
that they conform to the standard, internally they may cheat (not doing syntax
expansion, etc).

Greetings,

Peter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]