freenode/#lisp - IRC Chatlog
Search
5:50:39
beach
Hey gilberth. I am preparing my ELS talks, so I spend more time in #sicl than here in #lisp.
6:51:44
dtw
There are several command-line parser packages in Quicklisp distribution but I have been unhappy with all of them: too fancy object system which I don't want to use, too much automatic messages or return value is unnecessarily complicated to parse. So I have used my own parsers which I have now generalized and published as a package: https://github.com/tlikonen/cl-just-getopt-parser Maybe someone wil find that useful.
7:08:28
verisimilitude
This only affects those who live in countries that don't recognize public domain.
7:21:52
flip214
Is there a YAML parser that records line numbers on the input, so that meaningful error messages on _semantically_ invalid data can be thrown?
11:05:55
Th30n
Does anyone know why SBCL's sb-profile report different "consed" numbers for different calls of same function (or code)?
16:13:16
cl-arthur
I'm having trouble with a macro: (defmacro tt (ht) `(,ht (k) `(gethash ,k ,,ht))), and then (macroexpand-1 '(tt lowlink)) -> (LOWLINK (K) `(GETHASH ,K ,LOWLINK)).
16:13:25
cl-arthur
But my target is to expand into e.g. (lowlink (k) `(gethash ,k lowlink)). Having trouble figuring out how to get a simple "lowlink" into the double-backquoted list.
16:21:22
jmercouris
I have been thinking, if everything is an object, symbols must be objects, right?
16:21:47
jmercouris
and if symbols are objects, do they have two slots? one for a function, and one for a variable?
16:22:08
jmercouris
if it is an implementation detail, how does it work, on an implementation? I don't care which one, just curious
16:26:09
jackdaniel
in the past symbol property lists were used more extensively and there were indeed a slot for a function and a variable
16:27:02
jackdaniel
if you have a function denoted by a particular symbol, said symbol exists in your image
16:27:47
jmercouris
let's say we have package X and package Y, both package X and package Y use symbol Z
16:30:22
jmercouris
I'm trying to understand how the implementation knows that X::Z and Y::Z point to different things, and an example of how that is implemented
16:30:48
beach
jmercouris: All the standard says is that there exist functions SYMBOL-NAME, SYMBOL-PACKAGE, SYMBOL-VALUE, etc. It doesn't say how those are found.
16:31:26
beach
jmercouris: The implementation knows that they are different because the pointer values are different.
16:32:24
beach
jmercouris: Conceptually, every Common Lisp object is manipulated indirectly using a reference.
16:32:28
jmercouris
beach: so in your hypothetical example, you're saying pointers, are you referring to actual memory addresses (in the C sense) or just some symbolic address?
16:33:43
jackdaniel
the most straightforward way to the former is to peek in the actual implementation, and for the latter is to read in the spec
16:34:01
beach
jmercouris: The standard doesn't say what a symbol is. But here is the SICL definition of it: https://github.com/robert-strandh/SICL/blob/master/Code/Package-and-symbol/symbol-defclass.lisp
16:34:28
pjb
jmercouris: perhaps you would like to read an implementation of a package system? xach did one, which I completed. You can find it at: https://github.com/informatimago/lisp/tree/master/common-lisp/lisp-reader
16:35:03
pjb
jmercouris: alternatively, you could read The Complete Idiot’s Guide to Common Lisp Packages at http://www.flownet.com/ron/packages.pdf
16:35:07
jmercouris
my real real real meta question is why we insist on saying symbol X instead of var X or function X
16:35:59
pjb
There may be several variables named by the symbol X. There may be several functions named by the symbol X.
16:36:17
jmercouris
because it seems to be a very big distinction in Common Lisp, and I kind of get why, but I always like to confirm and reinforce my knowledge
16:36:45
pjb
(let ((x 42)) (cons x (let ((x 33)) (cons x (flet ((x () pi)) (list (flet ((x () 'foo)) (function x)) (function x))))))) #| --> (42 33 #<Compiled-function x (Non-Global) #x3020024F8B9F> #<Compiled-function x (Non-Global) #x3020024FAAAF>) |#
16:36:49
_death
methodologically "essentialism" is flawed, as it leads to trilemma of assumption, circularity, or infinite regress.. so instead of asking "what is a symbol", it's better to ask about how symbols behave, what operators you can use on them, etc.
16:37:04
beach
jmercouris: It is a convention I use so that the name of the slot will not be accidentally exported or used in SLOT-VALUE.
16:37:58
jmercouris
_death: I don't know, I figured it would be better to simply ask without assuming all questions that are salient *about* symbols whether it is how they behave or what they are
16:38:25
pjb
jmercouris: for example, I could implement a common lisp computer using wool braids. You would still call them references…
16:39:42
beach
jmercouris: Phrases such as "the function LIST" are short for "the function that has as its name the symbol LIST".
16:40:31
jmercouris
beach: could one also say something like "the function that is pointed to by the symbol LIST"?
16:40:32
pjb
(setf (symbol-function 'liste) (function list)) then the function LISTE is the same as the function LIST and it has two names…
16:40:48
jmercouris
because name, does a function ever actually have a name? just because a symbol points to it?
16:40:59
beach
jmercouris: No, because the symbol might not have a slot for the function, as you saw in the SICL definition.
16:42:16
pjb
Well, all functions are anonymous in a way: they're all created with (FUNCTION (LAMBDA …)), theorically. But named functions created with defgeneric or defun have their body wrapped in a block ,fname: (setf (symbol-function 'list) (FUNCTION (LAMBDA (…) (block list …)))) is what (defun list (…) …) does.
16:43:34
pjb
So there's theorically a way to distinguish "true" anonymous functions from defun functions, but also you can write (lambda (…) (block foo …)) and consider this anonymous functions could be named foo. Or bar. Or quux. This why even named functions cannot be considered differently than anonymous functions, fbound to some symbol…
16:45:20
beach
jmercouris: In the case of SICL, SYMBOL-FUNCTION is defined like this https://github.com/robert-strandh/SICL/blob/master/Code/Environment/standard-environment-functions.lisp#L132
16:45:22
jackdaniel
it may make sense to have a "name" property which captures its initial name (for instance for introspection)
16:45:40
pjb
(defvar *answer* 42) (let ((size 42)) (write-line "42 is named size and *answer*; is that even meaningful?"))
16:49:05
_death
in Lisp, we say that symbols are first-class objects, but we don't say how these objects are represented.. they have function cells and value cells that can be accessed using symbol-function/symbol-value.. they also have a name, an optional package, an a plist associated with them
16:50:20
jmercouris
yeah, that is however an error within the book a gentle introduction to symbolic computation :D
16:51:17
jmercouris
I think he is saying that they don't have to be associated in any way, it could be an arbitrary data structure
16:52:15
jmercouris
however, _death, are you saying that calling them cells does not imply an implementation spec, and that a cell is just an abstract way of saying that this bit of data exists with a relation?
16:53:03
beach
One could mean that, but it would be a very strange use of language to say that the symbol has a function cell if there is no such slot in the symbol.
16:53:04
pjb
On the other hand, it always has a plist. That's because (defun symbol-name (s) (get s 'apname)) (defun symbol-value (s) (get s 'value)) (defun symbol-function s (s) (get s 'fexpr)) were an implementation, once upon a time.
16:53:16
jackdaniel
from the spec (symbol-function): " Accesses the symbol's function cell. "; function cell: "function cell n. Trad. (of a symbol) The place which holds the definition of the global function binding, if any, named by that symbol, and which is accessed by symbol-function. See cell. ", cell: "cell n. Trad. (of an object) a conceptual slot of that object. The dynamic variable and global function bindings of a
16:53:22
jackdaniel
symbol are sometimes referred to as its value cell and function cell, respectively. "; so traditionally speaking Gentle is not wrong ;)
16:54:36
pjb
It's understood that those cells are "virtual" or abstract cells. Even CLOS instance cells don't necessarily represent an allocated place…
16:55:09
jmercouris
jackdaniel: if you look at the book, I would say it is definitely wrong despite the linked spec, because it shows very clearly some slots in a table for a symbol
16:55:11
beach
If so, symbols also have SETF function cells, method-combination cells, type cells, class cells.
16:56:41
jmercouris
I think you were working on something involving speculative execution of branches or something?
16:56:53
_death
beach: yes.. but this conceptual association relation I'm talking about is not a symmetric.. see Tversky et al. :)
16:57:10
pjb
anything we explain is always pedagogical metaphore. Even when you try to explain things in the most objective way.
16:57:33
pjb
The only exact explanations AFAWK would be to give the wave function of the system we want to explain.
16:57:38
beach
jmercouris: One sort of can, but it is then running inside a host and not as a proper executable.
16:58:23
jmercouris
there are most definitely bits, if we define a bit to be a charge or a lack of charge
16:59:07
pjb
Nope. You could have seen some lumps of copper and you may have counted 64 of them somewhere, but that's meaningless.
16:59:33
beach
_death: I think those associations depend on the person doing the association. I have long thought about SYMBOL-FUNCTION as accessing the environment rather than the symbol.
17:00:10
jackdaniel
I'm certain I did, I've even blinked a few times (or skipped the blink); 6 times in total
17:00:14
pjb
Using an oscilloscope, you might have observed some change in the electric electromagnetic field but this is still no bit. And no symbol, no lisp object nothing like it.
17:00:17
_death
beach: certainly it's a valid way of thinking, and can lead to useful representations
17:01:53
pjb
That said, CL doesn't specify those environements as first class objects (the other kind of environment are first class objects, even if there's no public constructor and they cannot be introspected in CL).
17:04:25
pjb
(defun symbol-function (x) (gethash x (function-table *environment*))) is another valid implementation.
17:04:41
beach
jmercouris: It can be the name of a function, a class, a method combination, a type, etc.
17:04:55
pjb
CL doesn't specify the implemention of CL operation, only their interface and semantics.
17:05:36
Bike
Are you asking what the difference is between the symbol "having" a cell, and the environment version?
17:05:46
pjb
AFAIR, there are only 2 algorithms specified in clhs: the reader algorithm, the backquote algorithm. (And we may infer one or two other algorithms more).