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: Fri, 16 May 2003 19:46:52 +0200

Peter Minten wrote:
> 
> 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.

It's also nice when this can be done dynamically on objects. Let's say we use
the following approach:
//inside classes
(include-interface class-name)
//for objects (singleton)
(obj.add-interface class-name)

> 
> 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.

Hmm, not really elegant yet. Let's say we have a class <pipe-set> which two
constructors:
(<pipe-set>.new)
(<pipe-set>.new keyword) //keyword = {:one-dir | :two-dir}

and four read-only fields: first, second, read-port (=first) and write-port
(=second).

A pipe-set contains two ports. It's not possible to see if a port is a pipe (bye
port.pipe field).

Greetings,

Peter



reply via email to

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