Questions tagged [clos]

Common Lisp Object System

The Common Lisp Object System (CLOS) is the facility for object-oriented programming which is part of ANSI Common Lisp. CLOS is a powerful dynamic object system which differs radically from the OOP facilities found in more static languages such as C++ or Java.

Source: Wikipedia (Common Lisp Object System)

187 questions
0
votes
2 answers

Why this symbol expasion is being malformed in Common Lisp?

I am trying to do the exercises on this tutorial about CLOS using SBCL and Slime (Emacs). I have this class, instance, and function to set values for the slots: (defclass point () (x y z)) (defvar my-point (make-instance 'point)) (defun…
Pedro Delfino
  • 2,421
  • 1
  • 15
  • 30
0
votes
1 answer

If CLOS had a compile-time dispatch, what would happen to this code snippet?

I am reading the Wikipedia article about CLOS. It says that: This dispatch mechanism works at runtime. Adding or removing methods thus may lead to changed effective methods (even when the generic function is called with the same arguments) at…
Pedro Delfino
  • 2,421
  • 1
  • 15
  • 30
0
votes
1 answer

print-method function behaves weirdly

I came across some strange behaviour when trying to customize the print-object function of a CLOS object. The function does generate the intended string, but it appears outside the object definition (i.e. followed by the string I…
Paulo Mendes
  • 697
  • 5
  • 16
0
votes
3 answers

Portable to use make-instance to make conditions?

In Common Lisp, is it portable to use make-instance instead of make-condition to make condition objects? For example: (define-condition foo (condition) ()) (make-condition 'foo) (make-instance 'foo) Does this have something to do with how…
Lassi
  • 3,522
  • 3
  • 22
  • 34
0
votes
1 answer

Request input regarding code style / best practices

I'm trying to implement a programming language in Common Lisp by following this implementation in Java (https://craftinginterpreters.com/control-flow.html). One of the things that was being really bothersome is plenty of slot-values…
Alberto
  • 565
  • 5
  • 14
0
votes
1 answer

Specifying the type of keyword arguments in Common Lisp methods

I thought i could define a method which accepts keyword arguments. But when i have multiple methods with keyword arguments of different types, it seems that lisp uses the last evaluated method. For example below: (defmethod f (&key (x list))…
user4813927
0
votes
1 answer

CommonLisp Function for dynamically looking up bindings in packages

Is there a way to dynamically ask for bindings in another package, and by dynamically i mean by not knowing the exact name of a binding in some package. A concrete case would be: As in package B, i know there exists a package A which has a certain …
user4813927
0
votes
2 answers

From file stream to assoc-list in common lisp

I have a file that starts with (defparameter *myfile* '(((KEY 1) (A1 CAN) (A2 4) (SUR (((BCZ S) (FEATS NIL)) (DIR FS) (LADOM ALL) (((NNEW S) (FEATS NIL)) (DIR BS) (LADOM ALL) ((NNEW NP) (FEATS…
Karavana
  • 489
  • 5
  • 19
0
votes
0 answers

Function to convert function to list in CLOS. Is it possible?

Is that possible to convert code to a list in CLOS? That is; is it possible to build a function that takes an argument f, which should be a function or method, and converts it to a List? The goal would be to visit the list elements in the same way…
0
votes
2 answers

What does it mean if a superclass state is not defined in Lisp?

My superclass is defined as follows: (defclass missionary-state (state) ((missionary-left :initarg :missionary-left :initform nil :accessor missionary-left :documentation "the number of missionaries on the left side of the river") …
Michelle
  • 265
  • 2
  • 14
0
votes
1 answer

Call to the next most specific method does not work

Consider the class account : (defclass account () ((name :initarg :name :reader name) (balance :initarg :balance :initform 0.00 :accessor balance) (interest-rate :allocation :class :initform 0.06 :reader…
Mooncrater
  • 4,146
  • 4
  • 33
  • 62
0
votes
1 answer

Installing CLOCC & packages

The comment by sds at Saving CLOS objects provides a reference to a Common Lisp Open Code Collection (CLOCC) file (closio.lisp) for printably reading & writing CLOS objects. Instructions for installing the software are at Installation of CLOCC.…
davypough
  • 1,847
  • 11
  • 21
0
votes
1 answer

Generic Function cannot find applicable method

When I call (draw win) I get an error the "generic function can't find applicable method. I have just gotten into CLOS and I am using sdl2kit to simply render a window. (defclass game-window (kit.sdl2:window) ((rotation :initform…
ZhangBing
  • 45
  • 1
  • 11
0
votes
1 answer

LISP: Get all slot names from an class instance

I need to make a window with the properties of a class (its slot-values). It would be something like describe function. My question is: How do I get all the slots-name for that class? I wasn't able to find anything about it, only the describe…
0
votes
3 answers

Common Lisp alternative to using Classes

I'm wondering how to store a single variable and to have specific functions on that variable. I'm wondering if there are alternatives to creating a class. Specifically, I am creating an application where I store a value for time that represents the…
audrow
  • 143
  • 1
  • 9
1 2 3
12
13