freenode/#sicl - IRC Chatlog
Search
14:03:33
jackdaniel
beach: I've noticed that you often say "an ordinary function or a generic function", is there an operator (in clostrum), which operates on one but not another? or could the passages be simply replaced with "a function"?
14:14:51
jcowan
An ordinary function isn't quite a generic function with a single method whose signature is t ... -> t, though in a CLOS-first implementation that would be a reasonable implementation strategy. You still need a flag saying "not really generic" so that you can signal an error on any attempt to add another method.
14:16:00
jackdaniel
jcowan: I'm not saying, that "ordinary functions" and "generic functions" are the same, only that both fall into the same category of being a function
14:20:55
beach
jackdaniel: It looks like you can replace the phrase "ordinary function or generic function" by just "function" everywhere.
14:21:50
jackdaniel
I was mostly curious if I'm not missing something by creating a single storage for all "function" definitions
14:22:11
jackdaniel
i.e if there is a need to have two hash tables: ordinary-functions and generic-functions
14:36:35
jackdaniel
strictly speaking, generic-function is a subclass of funcallable-standard-object (which is a subclass of function) afair
14:38:28
jackdaniel
compiled-function -> function <- funcallable-standard-object <- generic-function
16:05:34
jackdaniel
beach: I don't understand the specification of a funciton function-unbound (same applies to variable-unbound) -- if this function always returns a function, which signals undefined-behavior (which is eq for the same name and env), how can the client code be used to determine whether the function-name is unbound?
16:07:52
jackdaniel
right, but it is not clear to me, what is the purpose of this function, and why the passage "client code can use the return value of *this* function to determine whether /function-name/ is unbound"
16:09:47
jackdaniel
also, "when function-name has no definition as a function, the return value of this function is the contents of the cons cell returned by function-cell" -- otherwise what is the return value? freshly consed lambda? then it won't be eq if the function is defined later. I've made a workaround of that by storing the undefined-function lambda in the conse's cdr (so eq is preserved)
16:13:48
beach
Whenever a generic function is called that requires information about some function in the environment, if there is not yet a cons cell to hold the function, then one is created. If the call is to (setf fdefinition) then the cons cell is filled with the function passed as an argument. If not, the cons cell is filled with this function that signals an error.
16:14:34
beach
I guess I included the function-unbound function for clients who want to somehow alter the way the bound-ness is used.
16:15:30
beach
I say, include both of them. It doesn't cost very much. They just return the contents of a slot anyway.
16:16:35
jackdaniel
n.b I've implemented the function-cell (in the "virtual" subsystem) to be filled one called (i.e setf fdefinition does not eagerly create the function cell)
16:17:06
jackdaniel
please do, I think that the specification of the function-unbound is not very clear
16:18:13
beach
I don't understand what "I've implemented the function-cell (in the "virtual" subsystem) to be filled one called (i.e setf fdefinition does not eagerly create the function cell)" means.
16:19:23
beach
Normally, there is typically no information associated with a function name in the environment.
16:20:05
beach
As soon as client code requests some such information, an entry for a function is created (provided answering the request requires such a creation).
16:21:42
beach
Then an entry is created, a CONS cell is created in the entry, and a function is created that signals an error, and that function is stored in the entry and in the cons cell. Finally, the answer to the request is an error, because the function FDEFINITION signals an error if the contents of the CONS cell is EQ to the unbound function.
16:22:07
beach
If then, client code does (setf fdefinition), the cons cell is filled with the argument given.
16:22:29
beach
If, later, the client does fmakunbound, then the special error function is placed in the CONS cell.
16:23:48
beach
If you want to see how it is done, look in the First-class-global-environments directory in SICL.
16:25:08
jackdaniel
I think that implementing it straight from the specification may reveal some issues with it (also, I've implemented some of it already; that lead to this question)
16:25:48
jackdaniel
I will paste the code in a minute, first I want to formulate a next question based on your description above
16:30:14
jackdaniel
what you have described above implies, that you assume, that i.e fdefinition eagerly creates the function cell
16:30:37
jackdaniel
but it is not obvious to me from the specification, before asking the question I did it as pasted above
16:31:20
jackdaniel
i.e (setf fdefinition) would setf an entry in the functions hash-table, but it would not create the cell, the cell will be created only after the first call to function-cell
16:35:38
beach
Yes, fdefinition eagerly creates a function cell, but I don't think it has to be done that way.
16:37:23
beach
I guess you don't HAVE to create the cell, but you might as well, because you need to store the function somewhere.
16:38:50
jackdaniel
(I've added an annotation with (setf fdefinition) method https://plaster.tymoon.eu/view/1974#1975)
16:40:16
jackdaniel
I mean, I was implementing methods from top to bottom, and there was no single place where I had to use funciton-cell (yet), at least as far as function description were going (until I've encountered function-unbound, which description is not clear to me)
16:40:17
beach
You could store the argument to (setf fdefinition) in the function entry, and then copy it to the cell when the cell is asked for, but why the duplication of storage?
16:41:34
beach
I am a bit stressed because dinner is imminent, and I had to connect using a cable which is too short, so I am using the bad built-in keyboard.
16:42:07
beach
So I am reading the code, but I will very likely not understand it before dinner is served.
16:42:48
jackdaniel
function cells in the collection which is used to store functions (and access functions from cells)
16:43:10
jackdaniel
instead of what I did, that is store functions in one collection, and copy them to cells when requested
16:45:01
jackdaniel
you've said, that it is necessary to update function-cell when fdefinition is called, and that surprised me because it was nowhere specified and implementation without doing that works (however not optmially), that's why I have asked
16:47:24
jackdaniel
in light of that, should the specification stipulate that i.e fdefinition updates the function cell? or, if not, how should the specification of function-unbound look like (or should the function be removed)?
17:10:06
jackdaniel
OK, thanks to these missing bits of context now I understand what is the purpose of the function function-unbound. If we specify, that the undefined-function signalling function is stored in the function-cell's cdr, then I think that env:function-unbound is not necessary in the protocol. I'll implement it for now as it is specified.