I have returned to php development from Moose and I really miss CLOS like object model for php. Is there some kind of syntaxtic sugar which would allow me to write less code in php when dealing with objects?
Just to stress this requirement a bit more. I don't want to write one thing in several places. I can live with part of code being ...
Hi, im reading Practical common Lisp as a result of another question.
I just read chapter 16 and 17 where you can find how LISP manages objects. But after a couple of years of thinking how Java manages objects, i cant really seem to understand how you would implement bigger architectures in LISP using the CLOS.
So i ask you guys for s...
I'm running up against a problem in understanding the CLOS way of handling file access within a class. In c++ I would be able to do this:
class Foo {
Foo (string filename); // opens the file (my_file) requested by the filename
~Foo (); // close the file
FILE * my_file; // a persistent file-handle
DataStruct my_data; // ...
I'm forming a class for some work on molecular dynamics as follows:
(defclass %atom (particle)
((name :initarg :name :initform (error "Every atom in the system must have a name!"))
(mass :accessor mass :initarg :mass :initform (getmass name))
(charge :accessor charge :initarg :charge :initform (getcharge name))))
Initially I t...
What is the right way to define a generic in package A and to provide a method for this generic in package B in CLOS?
Thank you in advance!
Example:
(defpackage :common (:use :cl))
(in-package :common)
(defgeneric compare (a b))
(defmethod compare ((a number) (b number))
(cond ((< a b) -1)
((= a b) 0)
(T 1)))
...
I'm trying to change the value of an Editable-Text control in Allegro CL (version 8.0.1) by clicking a Default-Button.
I've read about (setf value) but haven't found any examples.
The function I have ttached to the on-click event is the following
(defun form1-default-button-2-on-click (dialog widget)
(declare (ignorable dia...
I have written a polynomial class along the lines described in SICP 2.5.3 (except using defclass). I would like to be able to seamlessly add and multiply polynomials and regular numbers but I can't make change-class accept a number.
I tried to simplify the problem by changing class from an integer to a float:
(change-class 4 'float)
...
I need to write a macro (with-hooks (monster method who what) &body body) for a game I'm writing. Monster is a CLOS object, method and who are strings and what is a function (#' notation). The macroexpansion would be something to the effect of
(add-hook monster method who what)
,@body
(remove-hook monster method who)
I have absolutely...
How do I see if one CLOS class is a subclass of another CLOS class?
...
If you want to make CLOS objects in common lisp printable (print readably), how do you go about doing this without using anything but print and read.
...
What all nice POOP (Prototype-based Object-oriented Programming) Frameworks
exists in Lisp and Scheme
I know one
* Sheeple
But I did not find any other.
...
In my class definition, I want to initialize one slot based on the value of another slot. Here is the sort of thing I would like to do:
(defclass my-class ()
((slot-1 :accessor my-class-slot-1 :initarg slot-1)
(slot-2 :accessor my-class-slot-2 :initform (list slot-1))))
However this doesn't compile:
1 compiler notes:
Unknown l...
I have a Node class that has an 'element' slot which contains a list with numbers and one letter, for example:
'(1 2 3 b 4 5 6)
(defclass node ()
((element :reader get-element
:writer set-element
:initform '()
:initarg :element
:documentation "The element"))
Part of the program is su...