Wednesday, April 05, 2006
Failed to get the memo
So I'm still working with Lisp Scheme guile,
and I'm still questioning if
Lisp Scheme guile is a HLL or a HHL-wannabe.
I'm at a point where using a structure would be the best thing to use. A structure is nothing more than a collection of data (possibly of different types) that can be treated as a unit. In C, a typical structure definition would be (example from my own code):
/* data associated with a web-request */
struct http
{
URLHTTP url;
List headers;
Stream io[2];
int version;
int status;
};
Pretty straight forward.
I check the the documentation and yes, it supports structures.
Cool!
So, here's how you define a “simple” structure with only two elements:
(define ball-root (make-vtable-vtable "pr" 0))
(define (make-ball-type ball-color)
(make-struct ball-root 0
(make-struct-layout "pw")
(lambda (ball port)
(format port "#<a ~A ball owned by ~A>"
(color ball)
(owner ball)))
ball-color))
(color ball) (struct-ref (struct-vtable ball) vtable-offset-user))
(owner ball) (struct-ref ball 0))
What? Did Lisp Scheme guile take
lessons from Forth? I have to manually construct the structures?
This is a HLL? And not only do I have to write code to create
structures, but I also have to write code to populate them. Anyone remember
BASIC?
10 DIM A(20):FOR I=1 TO 20:READ A(I):NEXT I 20 DATA 3,4,23,88,2,3,4,9,10,12,44,87,8,7,6,13,33,8,29,0
(Which, incidentally, is another pet-peeve of scripting languages—the inability to have pre-initialized data at run time.)
I suppose I could always write code to make structures easier, but why should I have to abstraction to what is arguably the highest level programming language in existance? (although structures might be easier to use in Common Lisp, I don't have a Common Lisp environment to test it) Have structures fallen out of vogue in HLLs? Did I fail to get the memo?
![Glasses. Titanium, not steel. [Self-portrait with my new glasses]](https://www.conman.org/people/spc/about/2025/0925.t.jpg)