Re: about genricity

From: David Fox <>
Date: 11 Sep 1996 11:18:52 -0400

In article <> Andre Gilles <> writes:

] When I want to read a class, I don't know how to do it in a clean way.
] Here is what I do
] (while not-eof-port
] read line on port
] if line match a regexp corresponding to child-class-1
] the create an instance of child-class-1
] (read child-class-1 port)
] if line match a regexp corresponding to child-class-2
] the create an instance of child-class-2
] (read child-class-2 port)
] ...
] Each time I create another heir of parent-class I have to modify this
] code. I find that this sequence of "if" is against the spirit of
] polymorphism but I can't manage to find another way to do it. Is there a
] classic way to handle such problems ?
] Gilles

Your output function could write scheme code to re-create the object,
like this:

          (require "child-class-1")
          (make <child-class-1> args...))

you could read it using something like this:

        (define restored-child-1 (eval (read port)))
David Fox		xoF divaD
NYU Media Research Lab    baL hcraeseR aideM UYN
Received on Wed Sep 11 1996 - 17:29:13 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST