A New prototype based Scheme/Lisp-Like Language

Whatever is on your mind, whether Lisp related or not.
Post Reply
underablackrainbow
Posts: 8
Joined: Mon Jul 04, 2011 7:00 am

A New prototype based Scheme/Lisp-Like Language

Post by underablackrainbow » Tue Aug 06, 2013 6:20 am

Hi everyone.

I need help from you for a good solution. I'm loosing my mind to realize a prototype-based Scheme/Lisp-Like interpreter with the philosophy that everything is an object. I like the solutions of T and the Yasos extension for the ability of make opaque objects. The interpreter must be realized in C from scratch (not as an extension on top of an existing one).

What I want: single inheritance and fixed structure object model (slots and methods cannot be added after object creation).

As I've wrote before, I like T and Yasos. However I've great problems with them: the inheritance and the type checking.

Keeping the following T example:

(define-predicate point?)
(define-operation print)
(define-operation equal?)

(define (make-point x y)
(object NIL
((point?) #T)
((print stream) ...)
((equal? pt) ...)

The type check is delegated to the "point?" predicate. But nothing can forbid me to make a fake object that answer with #T to the same predicate:

(define (make-fake a b c d e)
(object NIL
((point?) #T)
...))

The new objects will never be points also if they answer #T to the "point?" predicate. This solution is not acceptable for me since internal C structures must be accessed and checked easily. For example a string object must be always composed by a size and a pointer to the array of chars and the access to them cannot be done with a lookup.

The second problem is the inheritance: Yasos allow inheritance making the super-object on every object construction:

(define (make-3d-point x y z)
(object-with-ancestors ((a (make-point x y)))
...))

This solution give me the ability to mantain the opaqueness of objects but I've always the problem of the type check.

I try to explain what I mean. If I have an object <point>, the following instruction could make a new object with <point> as his ancestor.

(object <point> ...)

So to check if an object is a point I can use something like:

(is? X <point>)

However I can't make a 3d-point in this way:

(define (make-3d-point x y z)
(object <point>
...))

How the "<point>" part will be initialized? An INIT method have no sense since there is the make-3d-point or make-point lambdas.

Any Idea??

Thank you very much.
Tommy

Post Reply