freenode/#lisp - IRC Chatlog
Search
4:15:36
LdBeth
Is it possible to specify type for certain symbols, e.g. for symbol 'YES and 'NO, they have type 'Y-OR-N
4:29:57
LdBeth
I want to write a TCG card game, there’s certain attributes I want to check if is valid at runtime and retain the ability adding new attributes
4:57:20
beach
And I guess I don't see the purpose of the new metaclass, but that's probably normal, since I don't understand what the code is doing.
5:03:20
LdBeth
beach: I use metaclass because I want to avoid introducing a lot of global variables. That additional slot of metaclass stores allowed content
7:55:58
jackdaniel
from the "under the hood" perspective it is different. clrhash mutates hashtable object, while creating fesh hash-table constructs whole new one
7:56:31
jackdaniel
also if you have more references to that hashtable in your program, then clrhash will clear all of them
9:49:24
jmercouris
rather, has anyone in this channel done so, or know of a guide illustrating how to do so?
11:42:55
flip214
does somebody know of a higher-level interface to Ethereum than https://github.com/tsikov/ethi? something like https://web3py.readthedocs.io/en/stable/contracts.html or so?
13:11:47
jmercouris
when we assign a variable to a symbol, are we instantiating a new object of the class symbol?
13:12:30
jackdaniel
built-in class means: we pretened it is a class, but in fact it is internal datatype with shoehoerned aspects allowing dispatch on it
13:14:46
phoe
the first element of that list is the symbol DEFUN that was not created, because it is already present in the CL package
13:15:03
phoe
the second element of that list is the symbol FUNK that is not standard, therefore it could have been created automatically at read-time
13:15:32
phoe
so you get a data structure after read-time - a list containing symbols, lists, whatever else
13:16:58
Bike
if you have, say, (defun funk (x) x), the symbol X probably exists at runtime only for debugging reasons. The actual code doesn't need it.
13:17:03
beach
jmercouris: The function may not be pointed to by the symbol, and the symbol may not have a slot containing such a pointer.
13:17:27
beach
jmercouris: As long as your implementation answers correctly to (symbol-function <symbol>) it can do what it wants.
13:17:56
jmercouris
so basically what jackdaniel said right? the implementation has latitude to implement the "symbol class" however it likes
13:18:48
Bike
there is an API. the API says you can use symbol-function to get the function named by the symbol in the global environment. the API does not say anything at all about how this is accomplished
13:21:22
beach
jmercouris: And, in fact, in SICL, the association between function names and functions is stored in a first-class global environment. That way, this association can be different in different environments.
13:28:11
phoe
jmercouris: beach made a thing where you can have two different global environments. in each of these environments, you can DEFUN a function with the same name, but two different bodies.
13:28:14
beach
The Common Lisp HyperSpec mentions the "null lexical environment" also known as the "global environment".
13:29:06
beach
jmercouris: In SICL, I generalized this idea so that these environments are represented by first-class objects, making it possible to have several simultaneous but different instances of global environments.
13:29:10
jackdaniel
the practical gist of it is being able to have two different versions of the same library
13:29:39
phoe
disposable environments for compiling and building stuff and running pure-CL CI and other stuff
13:29:55
beach
jmercouris: Yes, multiple versions of a library, sandboxing, bootstrapping, cross compilation, etc, etc.
13:32:05
beach
jmercouris: There is a lot of stuff in the literature about modules for Lisp-like languages. A module is similar to an environment in that it is a mapping from names to values, as opposed to a package which is a mapping from symbol names to symbols.
13:33:22
jmercouris
and it is saying that the car of the first element is the symbol equal which has 5 slots
13:34:03
Bike
i mean, it kind of depends. there's no technical guarantee that a cons has to have any slots either, it just needs to have an accessible car and cdr. but it's convenient to graph it like that.
13:34:10
beach
jmercouris: Correct. And in SICL, symbol-plist is not in the symbol either. That too is in the environment.
13:34:32
jackdaniel
I like to think about symbols as of strings with strings attached (pardon the pun)
13:34:35
Bike
The basic thing to understand is that Lisp doesn't make any guarantees about pointers or whatever. It's just not part of the semantics
13:35:18
beach
jmercouris: Putting symbol-plist in the environment was natural once I decided to use first-class global environments.
13:38:13
beach
jmercouris: In fact, the definition is (defclass symbol (t) ((%name :initarg :name :accessor name) (%package :initarg :package :accessor package)) (:metaclass built-in-class))
13:40:18
Bike
what jackdaniel meant is that you can't do things with a built-in-class that you can do with a standard-class. for example you can't subclass it.
13:42:37
jackdaniel
I think you meant this quote: "< jackdaniel> built-in class means: we pretened it is a class, but in fact it is internal datatype with shoehoerned aspects allowing dispatch on it"
13:44:40
jackdaniel
my point was to emphasize that some parts of "everything is a class" is very artificial to keep the model consistent (especially when we talk about built-in classes). but now I regret I've shared that opinion (because it seems to bring a lot of confusion)
13:45:23
beach
jmercouris: You really really need to start thinking in terms of protocols (or APIs if you want).
13:46:01
jmercouris
which is an instance of #<SB-PCL:SYSTEM-CLASS COMMON-LISP:FUNCTION> on my implementation
13:47:22
phoe
jmercouris: the implementation creates instances of that class for you when you, for instance, (lambda () 42)
13:49:01
phoe
it grabs the LAMBDA *form* and returns an instance of a function based on the contents of that form
13:49:20
beach
xificurC: In most implementations, that bootstrapping process is very messy, either for historical reasons or because the system is built in a different programming language.
13:49:46
jackdaniel
jmercouris: it lambda essentially creates a function. since "everyting has a class" in common lisp, such function is an object of a certain built-in class
13:50:35
jmercouris
jackdaniel: so, lambda makes an instance of the function class? or did I misread?
13:50:40
jackdaniel
there is not much more into it, the only practical aspect is that you may specialize method on its class
13:51:00
phoe
the special operator FUNCTION grabs things and returns functions based on these things
13:51:35
beach
xificurC: In SICL, on the other hand, I use ordinary forms like DEFCLASS, DEFGENERIC, and DEFMETHOD to create this entire hierarchy: http://metamodular.com/CLOS-MOP/graph.png
13:51:39
jackdaniel
as I said, some "closiphology" is artificial. function is a function. to keep model consistent each function has a class associated with it
13:51:54
jmercouris
xificurC: I'm read Common LISP: A Gentle Introduction to Symbolic Computation, already read PCL, did a bunch of lisp programming
13:51:58
beach
xificurC: I can do that because I bootstrap using a full Common Lisp implementation, and I use first-class global environments.
13:53:49
phoe
.................why did I totally expect you to have a whole file dedicated just for that
14:06:35
makomo
you've probably seen it already, but appendix c deals with some of the circularities/bootstrapping problems
14:06:53
phoe
shka: beach: you both are right, I just wanted to write it for the sake of writing it. :D
14:08:05
xificurC
makomo: yeah, not sure if I'm gonna finish the book though as I haven't done much CLOS in order to fully understand and appreciate what lies underneath it
14:08:57
makomo
also, i realized yesterday that 3-lisp was the author's phd thesis and the first formalization of the concept of reflection
14:10:11
makomo
i've heard that sonya keene's clos book is a good introduction to clos itself. what do others think of it?
14:20:23
beach
makomo: Probably because it used examples that I either could not appreciate, or that required non-standard functionality.
14:22:56
beach
makomo: If I were to write a book like that, I would probably use more mundane examples like people, companies, employees, countries, etc.
14:23:50
makomo
beach: that's something that i wanted to comment on. aren't such examples better than the washed-out examples of animals, shapes, etc.?
14:24:20
makomo
i've seen one review where someone says that the book does actually go over the canonical animal/shape example, but that there are actual "industrial" examples afterwards
14:26:14
makomo
yeah, i don't think i do either, but i also don't recall ever seeing such a thing used in an OO introduction
14:27:59
beach
I mean, as if a person who happens to be a student is always going to remain a student and has always been one.
14:28:50
makomo
sometimes it just seems to me that more elaborate examples would be much better than the usual "we'll skip this, because it would take too much time" or w/e the usual "excuse" is
14:28:57
beach
I think that's the error in most books. They make class hierarchies that would absolutely not work in a real application.