dotgnu-visionaries
[Top][All Lists]
Advanced

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

Re: [Visionaries] WebScheme


From: Peter Minten
Subject: Re: [Visionaries] WebScheme
Date: Thu, 15 May 2003 18:43:14 +0200

The type checking on entrance of a function is useful but can be bothersome.
That's why I'm introducing interface inheritance. Interface inheritance
basically means a class implements the interface (the fields) of another class.
Note that with interface inheritance if a field does not exist yet a stub is
copied in, trying to read that stub results in an bad-interface-exception. An
instance of a class that uses interface inheritance can pass type checking
without actually fully inheriting of the needed class.

Interface inheritance is close to the C# interfaces, but doesn't require special
Interface objects.

--

WebScheme has a special casting mechanism. The (obj.cast target-class) method
returns the to target-class transformed value of obj or throws
bad-cast-exception. The nice part here is that this will actually work
consistent for all classes, no toString() or ->string methods are needed
anymore, one method fits all. Note that casting in WebScheme is defined by the
class who's instance is casted (or by the object itself in case of a singleton
cast method), (string.cast <integer>) may call (<integer>.parse string) while
(string.cast <array>) may call (string.split "").

--

The primary means of input and output in WebScheme are ports. This is the port
hiearchy:
<port>
  <file>
  <socket>
    <tcp-socket>
    <udp-socket>
  <string>

The <string> class is a port, you can write and read characters from it. The
method (string.write "FOO") appends "FOO" to the contents of string. The method
(string.read 3) returns 3 characters from the beginning string and removes them
from string. The method (string.read) simply returns the whole string and leaves
string empty.

There can be read-only, write-only and pipe ports. Read-only ports can only be
read from and write-only ports can only be read to. Pipe ports are an odd lot,
if you call the special pipe constructor (<port>.create-pipes :one-way) you get
a Pair containing in the value field a read-only port and in the next field a
write-only port. The ports are coupled to each-other, if you write something in
one it turns up in the other. If you call the constructor with the :two-way
keyword (or without a keyword) instead of with :one-way you get two read-write
pipes. Pipes always have the obj.pipe? read-only field set to #t, but they don't
tell where the other pipe is (because it can be out of scope or out of the
program).

The objects stdin, stdout and stderr are pipes.

Another use for pipes is communication in a multi-threading program.

Greetings,

Peter



reply via email to

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