* * * * *
Failed to get the memo
So I'm still working with [DELETED-Lisp-DELETED] [DELETED-Scheme-DELETED]
guile [1], and I'm still questioning [2] if [DELETED-Lisp-DELETED] [DELETED-
Scheme-DELETED] guile is a HLL (High Level Language) or a HHL (High Level
Language)-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 [3] and yes, it supports structures [4].
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 [DELETED-Lisp-DELETED] [DELETED-Scheme-DELETED] 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 (Beginners All-Purpose
Symbolic Instruction Code)?
> 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 [5].)
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?
[1]
http://www.gnu.org/software/guile/
[2]
gopher://gopher.conman.org/0Phlog:2006/01/26.2
[3]
http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/
[4]
http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Structures.html#Structures
[5]
gopher://gopher.conman.org/0Phlog:2006/03/09.1
Email author at
[email protected]