Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

...

Name: Anonymous 2009-03-26 22:23

I'm trying to make my own programming language with a syntax similar to lisp.  Not actual lisp though.  But right now I'm trying to work out how objects would work.  Currently this is what I'm looking at:

C-style:
ball.x = ball.x + ball.vx;

Mine:
(set (ball "x") (+ (ball "x") (ball "vx")))

Basically an object really is just a function that returns a reference to the member with the name in the argument (i.e. x).  This seems like it might be easy to implement, but there might just be a better syntax.

Any suggestions?

Name: Anonymous 2009-03-26 22:26

(ball 'x (+ (ball 'x) (ball 'vx)))?

Name: Anonymous 2009-03-26 22:29

>>1
Yes. Learn CLOS, and never speak of this thread again.

Name: Anonymous 2009-03-26 22:37

I don't see much point in including objects in a thing like this. Especially since it's trivial to create them as a library using lambdas.

Name: Anonymous 2009-03-26 22:37

>>4
Also generic functions are awesome. I agree with >>3.

Name: Anonymous 2009-03-27 0:24

>>1
(setf (assocq "x" ball) `("x" . ,(+ (ball "x") (ball "vx"))))

Name: Anonymous 2009-03-27 0:47

If you're poking at slots directly, you're OO wrong. The whole point is that an object manages its own godawful small affairs.

Name: Anonymous 2009-03-27 1:12

>>6

(setf (assoc "x" ball) `("x" . ,(+ (cdr (assoc "x" ball)) (cdr (assoc "vx" ball)))))

Terrible SICP programmer

Name: sage 2009-03-27 4:45

>>1

we all know that set! is this awful thing.

Grade A troll feed at wholesale prices! Does your troll's coat have a glossy sheen?

Name: ​​​​​​​​​​ 2010-10-22 5:53

Name: Anonymous 2010-12-17 1:17

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Don't change these.
Name: Email:
Entire Thread Thread List