freenode/#lisp - IRC Chatlog
Search
0:32:44
krwq
when loading file with quicklisp (possibly also asdf) why do function have to be defined in order (i.e. https://pastebin.com/qfYXGK5G but defining a first produces the error) - this makes sense to me if i executed them one by one but when loading the whole file I feel like this should just work
0:35:17
|3b|
and it returns name of output file, which you can LOAD, so (LOAD (COMPILE-FILE "foo.lisp")) is a common idiom
0:36:18
krwq
|3b|: no, does possibly :serial t in the asd file make any difference or is it just for order of files
0:37:08
|3b|
ACTION doesn't even get an warning from LOADing the example you pasted, is real code public anywhere? (on SBCL)
0:37:48
mfiano
I know about `closer-mop:slot-definition-initargs` which will give me the initargs given a class. But how would I discover initargs not present in the class? Like if I specialize a `reinitialize-instance` method, I would like to get those valid initargs as well. Basically I'm trying to get all initargs that can be supplied to `make-instance`.
0:38:26
krwq
|3b|: let me check if that's the warning or error - either way I'd expect debugger not to pop up
0:39:08
krwq
|3b|: actually i might be calling it when I think about it - i often put tests as top-level asserts under the function itself
0:39:10
Bike
make-instance initargs are slot initargs but the keys of allocate-instance and initialize-instance and shared-initialize
0:39:46
Bike
probably take all the initargs, and then look at the applicable methods for those three functions, and get the keywords out of those
0:40:28
krwq
|3b|: i think this might be related to the asserts, let me put them in the bottom of file and see if it works
0:42:14
mfiano
If this isn't vague enough, we're writing a DSL for a game engine, and we want compile-time type-checking for the part of the language that generates forms to create instances.
0:44:06
Bike
https://github.com/slime/slime/blob/master/contrib/swank-arglists.lisp#L780-L800 here's how swank does it.
0:45:55
krwq
|3b|: thanks |3b| - completely forgot about the asserts, i wrote the file a while ago and had to do some changes today when I hit this
0:46:37
mfiano
Ah, would you recommend your sandalphon parser, or something else? I always get frustrated when looking for things to parse lambda lists and just write my own special purpose hacks.
1:05:49
mfiano
Ok. I'm not very familiar with the MOP. What will give me the lambda list for reinitialize-instance?
1:08:07
Bike
you need the lambda lists for the methods of reinitialize-instance relevant to the particular class you're looking at
1:09:10
Bike
you can calculate those methods with compute-applicable-methods(-using-classes), then use mop:method-lambda-list
1:11:02
no-defun-allowed
how does the CLIM listener handle drawing graphical representations of values?
1:18:53
mfiano
Bike: I can get c-a-m to work, but I can't figure out how to get c-a-m-u-c to work. I just get a no applicable method error. Can you provide an example of using this?
1:20:02
aeth
I can parse function lambda lists except for &aux. It wouldn't take much to add method support because I designed it for my extended lambda list syntax that basically is the defmethod lambda list for types instead of classes and with the addition of &key and &optional support, which defmethod doesn't support.
1:20:38
aeth
It would take some work to librarify it, though, because I basically use it for define-function and related things, like local function bindings with the same syntax.
1:27:05
fiddlerwoaroof
no-defun-allowed: it uses a thing called "presentations" to associate a value with a particular display on the screen
1:27:26
fiddlerwoaroof
I'm not quite sure how the default representation of, e.g., repl results is handled
1:28:28
fiddlerwoaroof
Because WITH-OUTPUT-AS-PRESENTATION associates a value with the arbitrary display produced by its body, iiuc
1:31:17
mfiano
Bike: Stupid question. Why do I get an applicable method specialized on SB-PCL::SLOT-OBJECT in addition to the class specializer when computing methods for reinitialize-instance?
3:19:59
|3b|
there is sb-kernel:get-lisp-obj-address if you want to poke into internals (and understand that you will probably break things, and it can change at any time, unsupported, etc)
3:20:29
|3b|
keep in mind GC can move things around at any point, so for most objects that can change unpredictably
3:25:30
|3b|
(string-trim "#<>{} " (with-output-to-string (s) (print-unreadable-object (nil s :identity t)))) or something
9:03:50
asarch
In the lines #29, 45, 51, 59, 62 where *application-frame* appears, are they closures?
9:05:26
beach
asarch: *application-frame* is a special variable that contains an instance of a standard class.
9:14:04
asarch
Why when you declare a new class: http://paste.scsys.co.uk/582762?ln=on&submit=Format+it%21
9:16:48
asarch
I mean, when it is defined, you do something like (p1 point) at line #24, first the "instance" var and then the name of the class
9:17:19
asarch
And, in the line #44 of http://paste.scsys.co.uk/582761?ln=on&submit=Format+it%21 you do the opposite, (slider value)?
9:18:19
beach
It means define a method on the generic function DRAW that is only applicable when its parameter P1 is an instance of the class POINT.
9:19:31
beach
It means: Define a function named COLORS-SLIDER-DRAGGED with two parameters. The first parameter is named SLIDER and the second parameter is named VALUE.
9:20:15
beach
The reader of the code might guess that the value of the SLIDER parameter is indeed an instance of the class SLIDER.
9:20:47
asarch
I still have a lot of C in my mind that confuses me a lot with Common Lisp way of life :-(
9:30:57
asarch
So, the only way to "declare" a function with an instance of a class as one of its parameters is with DEFMETHOD?
9:32:51
beach
There is no need for anything like that, since classes do not imply encapsulation in Common Lisp.
9:33:44
beach
asarch: Maybe in your case, it is best to try to forget what you know about C or C++ when you work with Common Lisp.
9:33:57
TMA
asarch: that does not mean that a function defined by DEFUN is unable to accept arguments of the desired type. it is just that there is no discrimination on the type of the passed argument, unless you write the discrimination yourself
9:35:14
schweers
On the topic of encapsulation: is there a way to do proper encapsulation in Lisp? Not that I even found a need for it ...
9:36:24
schweers
goood question. I guess having some value which cannot be seen or even set by "outside" code?
9:36:49
schweers
I know and it has always been enough for me. But the hiding is based on convention, the language doesn’t enforce it.
9:37:13
beach
schweers: You define those things in a separate package and you don't export their names.
9:37:18
schweers
I do, I’ve never had the need for such a thing. But many people want it. Also, I’m curious. Hence my question
9:39:51
|3b|
closures tend to hide things in a way that is hard to get to, so you could use them if you really wanted to
9:40:13
schweers
So if a C++ or Java person were to come on here and ask how to do private members in CLOS or lisp in general, you’d rather explain why it’s misguided to enforce it in the first place?
9:40:22
heisig
schweers: Proper encapsulation sounds like you have to give up root permissions on your own computer. Even then, you could still physically destroy the computer :)
9:40:23
shka__
schweers: furthermore, it would be really difficult to have C++/java style encapsulation in dynamic language like Common Lisp
9:40:55
jackdaniel
schweers: if you want to encapsulate interfaces there is an easy solution for that: you put all in a package and export only "public" things
9:41:27
jackdaniel
as of preventing from direct slot access, you may name your slots with gensym (macro is needed) and enforce proper method interface via readers/writers/accessors
9:41:35
schweers
I think my question has been answered :) To be clear: I’m with you all, I was asking this as a hypothetical
9:43:03
jackdaniel
also that, connected with backtrace capabilities: you would be able to see who calls your method and see, if it is a "friend"
9:44:30
|3b|
also hard to compare features between languages. is the #define trick, or accessing 'private' slots with pointers comparable to accessing unexported symbols, or using MOP?
9:45:30
schweers
I have a feeling that accessing unexported symbols or even using MOP is more stable. But anyway, it was a hypothetical question anyway
10:04:51
shka__
it is very much used, and it is somewhat helpfull in some projects, but it comes with downsides and make dynamic style of programming PITA
10:05:44
shka__
but i used to work in crappy C++ corpo-projects full of outsourcing programmers and there encapsulation had it's place