[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon, 31 Jan 2005 16:50:29 +0000 
Subject:Re: How to read the sources 
From:Chris Dollin 
Volume-ID: 

Mystifier wrote:

> Thanks Aaron. You can find about Ruby at http://www.ruby-lang.org  My
> VM is at http://vuby.berlios.de/ . Though nothing of vuby is yet on
> web, but I plan to have them shortly.
> 
> I am considering to write VM in C++/C. Since Ruby shares a lot of
> features with lisp and small talk, I was interested in it. My major
> areas of importance was stack vs register based. What would be the best
> calling convention to be used. Do I use separate stacks for arguments
> and local variables ?

For many conventional languages (and Ruby counts as one such, I believe),
a single stack is sufficient. Parameters get pushed as part of the
evaluation of the function call; when you're inside the called function,
you address them stack (or frame) relative.
 
> In Ruby, we have lot of method calls (messaging) and I thought inlining
> them would be great.

For heavens sake, don't worry *now* about whether you should inline
things or not. *Especially* if you're using an interpreted VM. Get some
kind of minimal core working that you can experiment with.

All the performance speculation in the world is as nothing beside
measurements of real working systems. Write as much code as you can
*independantly* of which choices you make for method arguments/calls.
Then it's easy to see the effect of other choices. Even, with more
work, the effect of eliminating the option to ahve choices ...


-- 
Chris "electric hedgehog" Dollin
>From afranke@mathweb.org Tue Feb  1 08:47:51 2005
Path: news.demon.co.uk!mutlu.news.demon.net!peer-uk.news.demon.net!kibo.news.demon.net!demon!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!feed1.jnfs.ja.net!feed2.jnfs.ja.net!jnfs.ja.net!warwick!news-out.ftel.co.uk!bhamcs!news
From: afranke@mathweb.org
Newsgroups: comp.lang.pop
Subject: Re: Bug in poplog clisp: defclass :writer behaviour differs from
Date: Tue, 1 Feb 2005 08:47:51 +0000 (UTC)
Organization: cs.bham.ac.uk MAIL->NEWS gateway
Lines: 82
Message-ID: <ctnfnn$2dm$1@soapbox.cs.bham.ac.uk>
X-Trace: soapbox.cs.bham.ac.uk 1107247671 2486 147.188.192.10 (1 Feb 2005 08:47:51 GMT)
X-Complaints-To: abuse@cs.bham.ac.uk
X-Relay-Info: Relayed through cs.bham.ac.uk MAIL->NEWS gateway
Originator: exim@emily
Xref: news.demon.co.uk comp.lang.pop:1411

This is a multi-part message in MIME format.
--------------010706090204050202010402
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Aaron Sloman wrote:

> Could you send me a bit of lisp code to use for testing any such
> change please?

I have attached a test program; it's output should be self-explaining.

Btw, this is not a serious problem as it's easy to work around by using 
accessors
   (setf (a obj) val)
instead of writers, or alternatively by "ifdef"-ing for POPLOG:
   #+POPLOG (setf (w obj) val)
   #-POPLOG (w val obj)

But I haven't found a workaround for the 'let*' problem yet; using a 
macro to transform it into deeply nested 'let's with a single assignment 
each doesn't seem to help; the error stays the same.  Ideas are welcome.

Cheers,
Andreas

--------------010706090204050202010402
Content-Type: text/plain;
 name="writer_test.lsp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="writer_test.lsp"

;;;
;;; Testing :writer arguments in defclass slots
;;;

(defun verbose (expr)
  (format t "~S~%" expr)
  (eval expr))

(format t "~%Defining test class c ...~%")
(verbose '(defclass c () 
	    ((slot :accessor a :reader r :writer w))))

(defun test (f should-exist)
  (format t "   ~10A ..." f)
  (let* ((exists (fboundp f))
	 (ok     (equal exists should-exist)))
    (if exists
	(format t " is a defined function")
      (format t " is undefined"))
    (if ok
	(format t " (ok)~%")
      (format t " (*** NOT OK ***)~%"))))

(format t "~%Testing  :accessor a ...~%")
(test 'a t)
(test '(setf a) t)

(format t "~%Testing  :reader r ...~%")
(test 'r t)
(test '(setf r) nil)

(format t "~%Testing  :writer w  ...~%")
(test 'w t)
(test '(setf w) nil)

(format t "~%Creating test object o ...~%")
(verbose '(setq o (make-instance 'c)))

(format t "~%Trying to use :writer function w directly:~%")
(verbose '(w 42 o))

(format t " ... succeeded.  (r o) = ~S~%" (r o))
#+POPLOG (bye)
#-POPLOG (quit)

--------------010706090204050202010402--