freenode/#lisp - IRC Chatlog
Search
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).
17:06:09
pjb
But even those are only indicative: an implementation can use another algorithm behaving the same and those.
17:07:33
pjb
The thing is that you can both forget it or take it at face value, whatever helps you understand what you want to understand. (defstruct symbol name value function package plist) is a perfectly good explaination of symbols too.
17:07:50
beach
jmercouris: _death thinks that function cells and value cells are strongly associated with symbols, but not (say) classes.
17:07:56
jmercouris
pjb: the struct is actually how I usually imagine them in head, interestingly enough
17:08:00
Bike
i think this is something where you could talk about it for hours, or just write a simple interpreter and have it be obvious
17:08:48
jmercouris
beach: It makes sense though, why would a function cell be strongly associated with a class?
17:08:48
beach
jmercouris: I see symbol-function as similar to find-class, i.e. as operations on the environment.
17:09:02
pjb
(defstruct (symbol (:predicate symbolp) (:constructor make-symbol (name))) name (value *unbound*) (function *unbound*) package plist)
17:09:27
beach
jmercouris: Functions have names, so do classes. There is no particular reason to treat them differnetly.
17:10:00
_death
you can think of a symbol as an abstract data type, with certain behavior and various accessors, and any representation that fits that behavior will do
17:10:15
pjb
For example, one strong reason why we would want to have value and function outside of a symbol object, are threads (which are not specified in clhs). And having separate environments in the same lisp image is another reason.
17:12:35
beach
jmercouris: FDEFINITION also accepts names that didn't use to exist, namely (SETF CAR) and such.
17:15:14
pjb
(defun fdefinition (x) (etypecase x (symbol (symbol-function x)) (list (assert (eql 'setf (first x))) (get-the-setf-of (second x)))))
17:17:12
beach
jmercouris: Here is how I see it. In the old days, functions could only be named by symbols, so it was "natural" to store the function in a slot of the symbol, and to have a function called symbol-function. Then they introduced names such as (SETF FOO). Instead of adding a function symbol-setf-function, they created a new function FDEFINITION. It no longer mentions SYMBOL, so it is more "natural" to think of it as accessing the
17:18:30
pjb
Yes. Notice also that in the old time there were several kinds of functions fexpr, subr, etc. Nowadays, two kinds of functions can be bound to symbols: (symbol-function 'x) and (macro-function 'x).
17:19:26
beach
jmercouris: Given the name (SETF FOO), there was a need to find the corresponding function.
17:20:59
jackdaniel
that's why in cltl2 you could compare function names with eql and in ansi cl you can't (in the compiler)
17:21:03
pjb
But note that defun still use foo to name the block, not (setf foo), since block names must be symbols!
17:21:48
pjb
(defun (setf foo) (x object) (if (integerp object) (return-from foo x)) (error "expected an integer, not ~S" x))
17:21:49
beach
jmercouris: Because it is what (SETF (FOO 'BAM) 42) expands to if no setf expander has been defined.
17:23:11
jackdaniel
moreover, if you are not interested in being conforming: (defun (setf bar) (a b c object) …) (setf (bar 'xxx) (values 1 2 3))
17:23:28
beach
jmercouris: So now do you see why I don't think symbol-function or fdefinition are operations on symbols, but on the environment?
17:24:20
beach
jmercouris: And in fact, SYMBOL-VALUE probably doesn't access the "value cell" anyway, at least not in a multi-threaded Common Lisp implementation.
17:26:33
jmercouris
I'm going to rest as well, my mind is tired from thinking, thanks for the explanations everyone
17:39:11
_death
I think a good followup question you should have, with beach's model in mind, is why symbol-function and friends don't take an environment parameter
17:50:11
_death
also, weaker association between names and objects (first-classization) is something that appeals to many scheme-minded people
18:04:21
pjb
_death: that's because they're the standard API. (defun symbol-function (sym) (sicl:symbol-function sym sicl:*environment*))
18:06:02
_death
pjb: the begs the question.. I asked about the standard functions.. I agree that it's due to historical reasons
20:43:35
phoe
minion: memo for pfdietz: There's a comment I've made at https://github.com/phoe/package-local-nicknames-tests/pull/2 - did you have any insight about it so far?
21:14:30
phoe
Will the compiler then inline the code for these functions only in LOCALLY's lexical scope?
21:14:45
phoe
Like, if I declare A, B, C locally inline, and A calls B, and B calls C, will everything get inlined?
21:15:41
phoe
To define a function f that is not inline by default but for which (declare (inline f)) will make f be locally inlined, the proper definition sequence is:
21:24:54
phoe
If a function is locally inlineable, am I also able to compile it with different optimization settings?
21:25:23
phoe
Like, will I be able to compile it locally inline with speed 3 if the original function is compiled with speed 1?
22:41:24
pjb
phoe: you're doing something wrong: asking an implementation dependent question in #lisp instead of #sbcl or something.