<beach>
bollu: Did you see my answers to your SICL question?
<beach>
bollu: To begin with, you have the wrong number of semicolons for top-level comments, and your indentation is wrong.
jealousmonk has quit [Quit: ERC (IRC client for Emacs 27.1)]
<beach>
bollu: It looks like you are using lists where it would be better to use standard objects or structure objects.
<beach>
bollu: LET has an implicit PROGN so no need for an explicit one.
<beach>
bollu: Your naming convention with -> is not conventional.
s-liao has joined #commonlisp
<beach>
bollu: The code in your CASE should not be necessary.
<beach>
bollu: And names like BB and TY don't help the person reading your code.
<beach>
bollu: And comments like ";; then" and ";; else" just add noise.
<beach>
bollu: The number of blank lines between top-level forms seems completely arbitrary. Use exactly one blank like, or none in exceptional cases.
<beach>
bollu: And you are misleading the person reading your code by having a function named ASSERT-EQ that then uses an equality predicate other than EQ.
karlosz has quit [Quit: karlosz]
<beach>
bollu: This code would be much shorter, much nicer, and much safer, if you used standard classes rather than lists.
shka has joined #commonlisp
Lord_Nightmare has quit [Ping timeout: 240 seconds]
<moon-child>
bollu: (reduce (lambda (res x) (list res x)) ...) can be expressed simply as (reduce #'list ...)
Lord_Nightmare2 has joined #commonlisp
<moon-child>
bollu: GETTER should use EQ, not EQUAL, as it is comparing symbols
<bollu>
beach thanks a lot. I'll refactor this stuff using defclass and compare.
Lord_Nightmare2 is now known as Lord_Nightmare
<moon-child>
bollu: close parentheses should not go on their own line
<moon-child>
in EXPR->EVAL, why use NUMBERP rather than EXPR->IS-CONST?
monaaraj has quit [Ping timeout: 240 seconds]
monaaraj has joined #commonlisp
<bollu>
moon-child I should have used expr->is-const, you're right.
Algernon69 has joined #commonlisp
Algernon91 has joined #commonlisp
attila_lendvai has joined #commonlisp
amb007 has quit [Ping timeout: 256 seconds]
amb007 has joined #commonlisp
Algernon69 has quit [Ping timeout: 240 seconds]
<ns12>
remexre: What is SCL? Scieneer Common Lisp?
<remexre>
ns12: yeah...
<ns12>
Is it widely used?
<phoe>
not anymore
<phoe>
it's effectively dead - scieneer.com disappeared from the 'net
<ns12>
beach: "Your naming convention with -> is not conventional" - What is the convention for naming conversion functions?
<beach>
Well, these are not really conversion functions. They are accessors. And the best name for an accessor is the thing it returns like NAME for the name of an object, ADDRESS for an address of an object, etc.
<jackdaniel>
clx uses a->b, cffi uses a-to-b, the standard just specifies coerce and accessor like (STRING SOME-SYMBOL)
<jackdaniel>
s/coerce/COERCE/
<jackdaniel>
for conversion of course, as beach pointed out this is not really a conversion but a predicate
<jackdaniel>
the predicate name should be i.e EXPRESSION-CONSTANT-P (or in a form of an accessor)
<ns12>
Okay. Is it generally okay to use -> for conversion functions? For example, OBJ-A->OBJ-B.
<jackdaniel>
it is not unusual to see such function names; in LiSP author argues, that such functions should be named (OBJ-B<-OBJ-A ...) so the returned type is on the left (if I remember correctly)
<semz>
No CL standard function uses it to my knowledge, but you see them quite a bit, probably because Scheme uses them.
<jackdaniel>
well, standard doesn't have explicit conversion operators, except from the function COERCE
<ns12>
jackdaniel: Nowadays, does anyone follow the OBJ-B<-OBJ-A convention?
amb007 has quit [Ping timeout: 240 seconds]
<semz>
parse-integer, kind of. Yes, I'm reaching.
<jackdaniel>
I wouldn't call it a convention, rather a recommendation. I'm sure someone does, but I don't know about such codebase myself
amb007 has joined #commonlisp
<ns12>
What about the use of ! in the names of functions that mutate objects? Do Common Lisp programmers use ! like Scheme programmers do?
<moon-child>
conventionally they do not
<jackdaniel>
I saw it in a few libaries, but it is not common. a destructive version of FOO is NFOO (that's not the same as mutating, because you call them for the return value)
<ns12>
So how is mutation indicated? In the docstring?
<jackdaniel>
often it is indicated by a last letter f
<jackdaniel>
like (rotatef a b c)
<moon-child>
ns12: same way any other behaviour of the function is indicated
<jackdaniel>
or (maxf a 1 2 3) mind that the first argument is also taken into account for its value, not only as a storage place
<moon-child>
jackdaniel: I associate the letter f with a macro that mutates a place, not with a function
lisp123 has joined #commonlisp
<jackdaniel>
sure, it is. I've assumed that we talk about operators
<ns12>
What is the meaning of "F"? Does it stand for anything?
<jackdaniel>
'names of functions' may suggest otherwise, but organic macros in scheme are underutilized so that's probably the cause that function comes to mind first
<jackdaniel>
MODIFY
<jackdaniel>
at leasts that's how I interpret it, I don't know how I came with this association
<moon-child>
apparently it's 'function'
<jackdaniel>
and, as for functions a usual name would be (setf foo)
<jackdaniel>
i.e (setf (name <object>) 'silly!)
lisp123 has quit [Ping timeout: 256 seconds]
lisp123 has joined #commonlisp
mgl has joined #commonlisp
amb007 has quit [Ping timeout: 256 seconds]
amb007 has joined #commonlisp
lisp123 has quit [Ping timeout: 240 seconds]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
gaqwas has joined #commonlisp
Oladon has quit [Quit: Leaving.]
Jing has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lisp123 has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
notzmv has quit [Ping timeout: 268 seconds]
monaaraj has quit [Ping timeout: 256 seconds]
biog has joined #commonlisp
monaaraj has joined #commonlisp
Krystof has joined #commonlisp
nature has joined #commonlisp
rotateq has joined #commonlisp
gaqwas has quit [Ping timeout: 256 seconds]
miique has quit [Ping timeout: 240 seconds]
Posterdati has quit [Ping timeout: 240 seconds]
Posterdati has joined #commonlisp
monaaraj has quit [Ping timeout: 240 seconds]
monaaraj has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has quit [Remote host closed the connection]
Algernon69 has quit [Ping timeout: 240 seconds]
<jackdaniel>
where is the dsl?
<theothornhill>
well, it is the macros resembling defclasses. Dsl might be the wrong term
<jackdaniel>
you mean defenum, definterface, defobject and defschema?
<jackdaniel>
is there a reason for defenum args not be a &body argument (instead of a list)
<jackdaniel>
re definterface and defobject, why are they not "normal" defclass arguments?
<jackdaniel>
s/arguments/forms/
<jackdaniel>
with possibly a different metaclass and slot metaclasses to accept other argument types
<theothornhill>
because they need to resolve into parsed objects, so that we both can use the js-like language and define our own
<theothornhill>
that's my thinking, at least
thomaslewis has left #commonlisp [#commonlisp]
<jackdaniel>
well, these are clearly lisp forms, you may serialize it and deserialize with anything, you don't work on characters but on objects right?
<theothornhill>
yeah, I construct an ast, and these macros create ast objects manually
<theothornhill>
not quite sure I understand what you mean
<jackdaniel>
you've said that you have some specific syntax so objects can resolve into parsed objects, did I get that worng?
<jackdaniel>
s/worng/wrong/?
<theothornhill>
no, that's correct
<jackdaniel>
so, what I'm saying is that it doesn't matter what syntax you use, because serializer and deserializer work on data that is already read
rain3 has quit [Ping timeout: 268 seconds]
<theothornhill>
Right
thomaslewis has joined #commonlisp
<rotateq>
so many strings :)
thomaslewis has left #commonlisp [#commonlisp]
<theothornhill>
<3
<theothornhill>
yes, I don't really like that, but it might be better than changing the reader for casing?
<rotateq>
yes sure, for the ones that aren't all uppercase
<theothornhill>
true
<jackdaniel>
if this is about to expand to defclass then these would be slot names
<jackdaniel>
both :bar-initarg and foo-initarg are symbols
<jackdaniel>
the initarg must be a symbol
<jackdaniel>
(not not necessarily a keyword)
<bollu>
Hmm, then I don't understand what a symbol is. I thought a :symbol was some kind of flyweight object that's efficiently allocated, while 'symbol is .. something else (I'm not sure what)
<jackdaniel>
:foo is a symbol in the package keyword, these symbols are kind of special, because they evaluate to themselves
<jackdaniel>
foo:xxx is a symbol XXX in a package "FOO"
<jackdaniel>
:xxx is a symbol named XXX in a package "KEYWORD"
<bollu>
mm
<bollu>
I feel there is some inconsistency still. In the declaration of foo, I use [foo-field :initarg foo-initarg] while for bar, I use [bar-field :initarg :bar-initarg]. The [foo-initarg] is not a symbol. Why is this accepted?
lisp123 has joined #commonlisp
<bollu>
I'm not doubting your explanation, merely trying to understand if I'm missing something still.
<beach>
foo-initarg is a symbol.
<bollu>
Oh, I'm not reading right
<bollu>
I see
<bollu>
I thought 'foo-initarg was a symbol, with the quote.
<jackdaniel>
quote prevents evaluation
<bollu>
what is a symbol, then? is every identifier a symbol?
<bollu>
(and things of the form :<identifier> ? )
cosimone has joined #commonlisp
<Alfr>
bollu, result of (make-symbol "some-name").
cosimone has quit [Remote host closed the connection]
<jackdaniel>
stand that way for 15m on tips of your toes
<jackdaniel>
:)
<phoe>
now that's a challenge
<bollu>
Nice, thank you!
<bollu>
CL-USER 30 > (make-symbol "foo") #:|foo| I have not seen #:|...| anywhere else. should I have encountered it in the wild before?
<Xach>
bollu: maybe
<jackdaniel>
#:|foo| is composed of two reader macros
<jackdaniel>
#:xxx means a symbol without package
<jackdaniel>
|xxx| means a symbol with a name "xxx" (as opposed to i.e "XXX")
<jackdaniel>
so #:|foo| means uninterned (without package) symbol with a name "xxx"
<random-nick>
| isn't a reader macro
cosimone has joined #commonlisp
<random-nick>
it's defined as a "multiple escape character"
<jackdaniel>
OK, me top tops on his toes
<jackdaniel>
s/top/tip/
<bollu>
:)
<bollu>
okay, neat, thanks! I go back to fixing my shoddy lisp as per beach's feedback
<beach>
bollu: Also, really, I am serious by being careful with what you mean by "is".
<beach>
bollu: When the reader sees the sequence of characters 'hello, it does not return a symbol.
<beach>
bollu: It returns a list of two symbols: (QUOTE HELLO)
<beach>
bollu: So a more accurate statement than "is", would be "in a context of evaluation, the form 'hello evaluates to the symbol named HELLO".
<bollu>
beach the rephrasing is very helpful.
<beach>
bollu: The rest depends on the evaluation rules and some other things. Like when the reader sees :hello, it returns the symbol named HELLO in the keyword package. But as it turns out, when the evaluator sees a symbol in the keyword package, it returns the same symbol as a value. That is not the case with other symbols.
<phoe>
;; ...with *most* other symbols - some of them are defined to evaluate to themselves, most notably the constants T and NIL
<beach>
Right.
<jackdaniel>
(defvar phoe 'phoe)
<phoe>
;; but keywords are the group of symbols for which this behavior is required - all it takes is interning a symbol in the KEYWORD package for that symbol to gain the magical properties of a keyword
<phoe>
also what jackdaniel just said
karlosz has quit [Quit: karlosz]
<beach>
bollu: So this is why, again in the context of evaluation, a symbol such as HELLO by itself evaluates to the value of HELLO as a variable, whereas a symbol such as :HELLO evaluates to itself.
<jackdaniel>
btw lately I find myself more often writing (function foo) in macro definitions (as contrated to function bodies) than #'foo
<jackdaniel>
it makes all that quoting and unquoting much less cryptic
<jackdaniel>
and (quote foo)
<bollu>
jackdaniel that's very neat.
<bollu>
jackdaniel (the defvar)
tyson2 has quit [Remote host closed the connection]
amb007 has quit [Ping timeout: 256 seconds]
<jackdaniel>
I like being complimented, keep going! ;)
* jackdaniel
leaves the office, see you \o
<bollu>
see ya!
amb007 has joined #commonlisp
<bollu>
beach A stylistic question. If you recall the code review you did for me ~12h ago, I had functions like expr->eval. You mentioned this was bad form. What would you name such a function?
<bollu>
I am considering expr-eval
<bollu>
but I am not sure
<beach>
I need to do that tomorrow. My (admittedly small) family just announced that dinner is served. Sorry.
wheelsucker has joined #commonlisp
<bollu>
beach enjoy!
Oladon has joined #commonlisp
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jackdaniel>
what does this function do?
<jackdaniel>
evaluate-expression would be a good name if it evaluates the expression
<etimmons>
Xach: Is Planet Lisp broken or is it just my feed? Some posts from yesterday aren't showing up.
<Xach>
etimmons: could be both!
<lisp123>
Last post 36 hours ago here
<lisp123>
Xach: Who owns lisp.org?
<lisp123>
What a domain...
<lisp123>
*drools*
<bollu>
jackdaniel it evaluates expressions, yes
<Xach>
lisp123: franz
<yottabyte>
in emacs, how do I load the entire file? so that every function and what not is available in slime
<Xach>
etimmons: i get 404 for the feed. did it move and i didn't know about it?
<Xach>
yottabyte: slime-load-file is one way
<lisp123>
Xach: Thanks. That's very nice of them for the home page.
<phoe>
you'll want to define a package MY-EVAL (or some other name) and shadow symbols like NUMBER and SYMBOL
<bollu>
hmm
<semz>
If expr-eval is a generic function, you can define a method specialized to number or string. The CL classes number and symbol can't be made subclasses of your own classes, although you could make your own classes with that name.
<semz>
the latter is basically what phoe said
<bollu>
semz is it considered good practice to specialize a generic function to primitive types like number / symbol / string? (expr-eval is indeed a generic function)
<Xach>
etimmons: thanks, that works
<phoe>
yes, what semz said - depends on whether you'd like to reuse CL types
<phoe>
bollu: yes
<phoe>
s/types/classes/
<bollu>
right, sorry :)
<semz>
Definitely common.
<bollu>
I come from static typing land, mostly
<bollu>
nice, okay! thanks
ns12 has quit [Quit: bye]
ec has quit [Quit: ec]
ns12 has joined #commonlisp
ec has joined #commonlisp
<etimmons>
Xach: awesome, thanks!
<lisp123>
Can see the new post now
<lisp123>
etimmons: congrats on the release
<Xach>
etimmons: thanks for letting me know (possibly more than once) the correct link
<etimmons>
lisp123: Thank you!
Inline has joined #commonlisp
<etimmons>
Xach: No worries. I think there was just a transcription error on one side or the other when I changed it. Or, more accurately, decided that I may blog about more than common-lisp some day
eddof13 has joined #commonlisp
jealousm` has joined #commonlisp
jealousmonk has quit [Ping timeout: 240 seconds]
jealousm` is now known as jealousmonk
<etimmons>
Xach: Also, if I were interested in making the new repos Twitter bot look at Gitlab as well what repo should I look at?
sloanr has joined #commonlisp
sloanr has quit [Remote host closed the connection]
eddof13 has quit [Ping timeout: 240 seconds]
<bollu>
how do I compare classes for structural equality?
<Xach>
bollu: there is nothing built-in to do that.
<bollu>
Xach what are my options?
<etimmons>
Any Sly users know if there's a way to get an _inferior-lisp_ buffer like SLIME's? Sometimes I have messages printed before the mREPL starts that I want to see
<bollu>
Xach I'm trying to write an algorithm that needs persistence, so being able to write immutable style code and check structural equality would be very very useful
<lisp123>
there should be a class equal function in there
<drakonis>
it improves on nix in a myriad of ways but retains some design decisions due to reusing the nix daemon
<lisp123>
Note this requires you load the CLOSER-MOP package from quicklisp
<lisp123>
Take the relevant bits from the file (e.g. the last line will not work)
xaltsc has quit [Read error: Connection reset by peer]
<Xach>
etimmons: there *are* some uncommitted changes to ghprojects
<jstoddard>
drakonis: If you implement guix in CL, I'll gladly try it out. I have been interested in trying out guix, but haven't gotten around to it.
<Xach>
etimmons: I'll see about pushing them later today
<etimmons>
drakonis: I bet I'd actually like it. IIUC, once you enter a guix environment it's basically like a fresh OS where everything is available with the standard names and so on. And I realized by biggest complaint about Roswell was it didn't do that
<drakonis>
i would like to reimplement shepherd in cl as well
<etimmons>
Xach: No rush, I don't have any time budgeted for it soon. Just going to idly look and think for a while
<Xach>
etimmons: have you seen djb's remarks about packagers?
<etimmons>
I don't think so
<drakonis>
then actually get rid of the dependency on the nix daemon so i can use the daemon for deployment, build scheduling and monitoring
<drakonis>
2001? that's pretty much about the unixen
<drakonis>
not linux distros being mutually incompatible
<etimmons>
Xach: The first two examples (apache) brought some bad flashbacks to when I first realized that not every distribution put files in the same place
<Xach>
i'm glad he won and everything is consistent now
thomaslewis has left #commonlisp [#commonlisp]
<etimmons>
ha
miique has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
<drakonis>
ha indeed
amb007 has joined #commonlisp
<drakonis>
cl-tar is highly appreciated.
<drakonis>
i certainly wonder something now, if i have a sufficient amount of external libraries, how prone am i to breakage?
<drakonis>
especially libraries that aren't 1.0?
<etimmons>
drakonis: Somewhat. I think most CL projects do a good job about not breaking things, but breakage does happen occasionally.
Algernon666 has quit [Read error: Connection reset by peer]
<drakonis>
jstoddard: it is worthwhile to try it out, if i actually finished the prototype, it'll look a lot like guix
<etimmons>
Frequent CI runs help (not just when you push, but also periodic to get updates from your deps)
<drakonis>
before actually engaging into a total makeover
<etimmons>
And if you add your project to QL, Xach will let you know if your project fails to build due to a dep change. But I don't think he runs tests, just compiles
<drakonis>
tbf, guix and nix have CIs for their package ecosystem
<drakonis>
so that gets avoided
<drakonis>
lots of package pinning is done to avoid breakage due to upstream updating
<drakonis>
it is fascinating
<etimmons>
And there are other approaches as well, like CLPM and Qlot that let you create pinned environments.
<etimmons>
But if you go that route, you definitely want to have your CI occasionally bump your deps so you don't get too far behind
<drakonis>
yeah.
<drakonis>
that's the same approach
<etimmons>
(shameless-self plug): I do have Gitlab CI scripts for CLPM that will automatically bump your deps and open an MR. That then triggers your regular CI tests so you can see if there was breakage
<drakonis>
i do want an escape hatch for ignoring pinning
<drakonis>
since guix does not provide it the easy way
<drakonis>
nix has it hidden under layers of indirection and code
<drakonis>
brb
<etimmons>
drakonis: That's pretty easy to do. pining is typically done with a separate file and requires no modification to an .asd file. So just ignore the extra file and load the system however you want to
<etimmons>
* pinning
igemnace has quit [Ping timeout: 268 seconds]
<etimmons>
As a concrete example, I use CLPM to manage my dev and testing env for cl-tar. But it'll still work via QL (once the next dist hits) or just dropping it onto your ASDF source registry.
<drakonis>
not going to make it cl specific tho, as it would defeat the point of the rewrite
<drakonis>
also brb soon
Alfr has quit [Remote host closed the connection]
Lord_of_Life has quit [Excess Flood]
Inline__ has joined #commonlisp
Inline has quit [Remote host closed the connection]
Alfr has joined #commonlisp
<etimmons>
Ah, I missed the part about reimplementing shepherd
<etimmons>
I was still firmly in CL land :)
amb007 has quit [Read error: Connection reset by peer]
Lord_of_Life has joined #commonlisp
<lisp123>
Quick one, is there a version of loop that collects for a vector not a list?
<etimmons>
(and trying to convince myself I'm not one of those integrators that introduces incompatibilities to lock users in :P)
<aeth>
lisp123: no, but depending on what you're doing, you can use MAP or MAP-INTO instead
<aeth>
(i.e. if you can write the iteration as a lambda)
<lisp123>
aeth: thanks, i'll use MAP and maybe write a mapcar equiv for vector
tyson2 has joined #commonlisp
amb007 has joined #commonlisp
<lisp123>
"MAPV"
<aeth>
that's basically what MAP is when the second argument isn't NIL or 'list afaik
<aeth>
it's just that there are a lot of different kinds of vectors
<aeth>
maybe MAPSV if you're going for a 'simple-vector
<lisp123>
good point re different kinds of vectors
<lisp123>
I guess that's why MAP requires the sequence type to be specified
<lisp123>
ehh maybe I just use lists again lol
<rotateq>
lol lisp123 :D
<lisp123>
too much work with vectors sometime
<lisp123>
rotateq: :D
<rotateq>
we had this discussion in the past, i remember :P
<lisp123>
did we? wouldn't be suprised, I keep going in circles O
<bollu>
I see. That's counter-intuitive to me. Why do I need to supply the class as well? [I suspect the answer will be 'it's complicated...'?]
<bollu>
thank you
<phoe>
bollu: because you are not calling slot-value, but slot-value-using-class
<Bike>
so that you can specialize methods on the class of the class, rather than the class of the slot definition
<phoe>
and the class is there in order to figure out which method to call
<bollu>
phoe wouldn't the object know which class to use for a given slot?
<phoe>
it does
<phoe>
that's why slot-value automatically finds the class object
<phoe>
...not the class object, sorry
<Bike>
slot-value-using-class is less intended as an interface for programmers to call themselves, and more as one programmers can customize when they're customizing how the object system works.
* phoe
apologizes, too late for him to explain mop at the moment
<Bike>
another possibly simpler way to do it would be to get the slot name from the slot definition, and then just use slot-value
<rotateq>
ah bollu, what brought you to using lispworks in the first place? :)
<bollu>
rotateq I find the UI more predictable than emacs :)
<rotateq>
ok
<Bike>
if you're using lispworks exclusively, you probably don't need to bother with closer-mop or loading or anything
<Bike>
i imagine the clos package is already exposed for you
<bollu>
Bike do you know how I would load clos directly within lispworks? I tried (require "clos"), but it doesn't look like that's it. (require "clos") Error: Unknown module "clos".
<bollu>
Bike it appears that clos:slot-value-using-class needs the slot *name*, and not the slot itself. I guess I get the slot name with CLOS:SLOT-DEFINITION-NAME?
<phoe>
huh?
<Bike>
that appears to be a peculiarity of lispworks, indeed. yes, that's the function you want.
<bollu>
thanks!
<Bike>
more reason to use slot-value, i guess
rgherdt has quit [Ping timeout: 250 seconds]
<phoe>
...or to use c2mop
<Alfr>
phoe, is (#:use ..) as an defpackage option defined?
<phoe>
oop
<phoe>
s/(#:use cl)/(:use #:cl)/
<phoe>
same for #:local-nicknames
<phoe>
time to go to sleep
* phoe
sleep
perrierjouet has quit [Remote host closed the connection]
<bollu>
how does one define a "default" method for a generic? Does a defmethod with no type annotations do the trick?
<aeth>
phoe: I never got around to spinning it off or incorporating the suggestions from this channel (or was it the old #lisp one?) last time it came up
Algernon91 has joined #commonlisp
contrapunctus has quit [Quit: Gateway shutdown]
lisp123 has joined #commonlisp
<jstoddard>
White_Flame: There is a small difference, if I understand the spec correctly. (defmethod foo (bar) nil) will result in a warning about the unused parameter, while (defmethod foo ((bar t)) nil) does not warn.
<phoe>
aeth: thanks, I'll remember to remind you soon™
<bollu>
pjb ah, I totally missed that distinction the first time around.
<bollu>
Do I need to think about whether what I am doing is safe under REPL reloads every time I define a thing in CL? It seems to me that defclass is preferred over defstruct because it behaves better with respect to changes in the REPL?
<Bike>
it's not really repl specific, but yeah, defclass has defined redefinition semantics and defstruct does not.
<bollu>
Bike are there other constructs that do not have well defined redefinition semantics?
<Bike>
hmm. off the top of my head, proclamations, probably
Algernon91 has quit [Quit: Leaving]
<bollu>
Another feeling that I get is that common lisp is "large" as a language. Is this unfounded?
<Bike>
it has a big standard library and stuff, sure.
monaaraj has quit [Ping timeout: 256 seconds]
sloanr has quit [Remote host closed the connection]
monaaraj has joined #commonlisp
sloanr has joined #commonlisp
<pjb>
bollu: nothing old is large. Android was 3500 classes and 350,000 methods a few years ago. Probably much bigger nowadays.
rgherdt has joined #commonlisp
<bollu>
Bike do you consider CLOS as part of the stdlib? or as part of the core language
<Bike>
of course.
<Bike>
the metaobject protocol isn't part of the standard, but the object system definitely is
<bollu>
Bike I am unsure if the of course refers to it as stdlib or core language ;)
<bollu>
Now I have another problem as I migrate from raw lists to classes: I need to write my writers!
<bollu>
is there a cheap way to get a decent pretty printer?
<sm2n>
(format t "~a" ...)?
<Bike>
print-unreadable-object is helpful usually.
<Bike>
the standard library is part of the core language. lisp isn't like C or something where there's an alternate "freestanding" version.
<bollu>
sm2n that prints the pointer, yes. But not the actual memory
<bollu>
But not the actual data*
<bollu>
Error: The symbol "PRINT-UNREADABLE-OBJECT" is not external in the CLOS package.
<bollu>
Hmm
<Bike>
print-unreadable-object is part of the standard library, i.e. in the CL package
<Bike>
there is no standard way to dump the actual memory. the lisp system does not define anything about memory
<sm2n>
Right, if you're printing an object what you want to do is (defmethod print-object ((o my-class) s) ...)
<sm2n>
usually you put print-unreadable-object in there
<sm2n>
judging by your previous posts, you are probably familiar with haskell, so that is like implementing Show
<bollu>
yes, I'm familiar with haskell. and thanks, that makes sense
<Bike>
what exactly do you expect? automatic printing of all the slots and their values?
miique has quit [Ping timeout: 240 seconds]
gaqwas has joined #commonlisp
sloanr has quit [Remote host closed the connection]
<Bike>
if you want to just see what makes up an object, you can use cl:describe. but that's not suitable for anything programmatic, which is what i think you're doing?
sloanr has joined #commonlisp
<bollu>
Bike yes, I was indeed hoping for automatic printing
<bollu>
pjb thanks!
<bollu>
Bike what does one usually do? write custom printers?
frgo has quit [Ping timeout: 256 seconds]
<Bike>
usually. it depends on what you are doing.
<Bike>
for example, most of the time i don't want all slot values printed, since i'm working with complex graph structures. so i define a printer that only prints the name or some other identifier.
<Bike>
if i wanted to actually de/serialize objects with a text format, i'd need to do something else
<bollu>
I see. I'm prototyping a compiler optimization. I just want to debug print the IR. The output of cl:describe is actually quite close to what I want. All I need is for it to print the slots on a single line
<sm2n>
Are you familiar with the inspector?
<Bike>
really? IR is in fact what i usually work with. well, if that's what you want
<bollu>
Bike yeah. I have basic blocks, but small ones, so I don't mind just scanning it by eye.
<bollu>
sm2n I'm not.
<sm2n>
You may want to explore that then
<_death>
defstruct generates a default printer that prints all slots.. sometimes it's useful, but often you don't want to print some of the slots, so have to define your own function/method.. defclass's default printer just displays the class name and the instance's "identity", but you can define a print-object method to print more slots
<sm2n>
Shouldn't that print stuff, not return data structures?
<sm2n>
also, you can replace the let* in loop with for = ...
<sm2n>
i.e (loop collect (let* ((a 1) (b 2)) (+ a b)) is functionally equivalent to (loop for a = 1 for b = 2 collect (+ a b))
<sm2n>
additionally, you can use list as a variable name, and it won't collide with the function list, since they are in separate namespaces (rather than xs)
<bollu>
sm2n hm, I feel I mischaracterized what I wanted. I wanted something that was quick and dirty to stare and and feed back into the repl quickly if need be. So I opt for returning a list for more manipulation
<sm2n>
There's also a built-in flatten function, but that works on trees (arbitrary levels of nesting), but should work fine here
<bollu>
sm2n oh, the loop = is neat
<bollu>
sm2n I prefer `xs` as a variable name tbh.
<sm2n>
sure, you do you, it's not really conventional though
<bollu>
sm2n lispworks doesn't seem to know flatten
<sm2n>
I code switch a lot when programming depending on the language, sometimes surprising even myself
<bollu>
sm2n oh? I see. in common lisp convention, I'd write `list`, I take it?
Inline has joined #commonlisp
<sm2n>
oh, whoops, flatten is in the alexandria package
<sm2n>
I use it often enough that I had forgotten
<sm2n>
and yes
<sm2n>
and I guess another thing I would change is to specialize your last method on standard-object
<bollu>
sm2n what are things other than standard-object, number, symbol? I guess.. string?
<sm2n>
yeah
<sm2n>
I would probably make the default case the identity instead
<sm2n>
also, your method will fail on improper lists
<bollu>
sm2n how do I fix it for improper lists
<sm2n>
there are essentially two types of improper lists
<bollu>
I don't know this. I only the ones of the form `(a . b)`
<sm2n>
(chains of) conses that don't terminate with a nil, and circular lists
<sm2n>
you described the first type
<sm2n>
the second looks like #1=(1 2 3 #1#)
<sm2n>
err
<sm2n>
#1=(1 2 3 . #1#)
<sm2n>
this will lead to an infinite loop if you don't do cycle detection
<bollu>
ah
<bollu>
mh
<sm2n>
the printer/reader have logic for this built in toggled by *print-circle*
xaltsc has joined #commonlisp
<bollu>
damn I don't want to implement the two pointers algorithm for my dinky throwaway debug code :)
<bollu>
can I invoke them?
<bollu>
the printer?
<sm2n>
yeah I wouldn't bother
<bollu>
right
<sm2n>
well, you can to print
<sm2n>
that's what your repl does
<sm2n>
and format etc
gaqwas has quit [Ping timeout: 240 seconds]
<sm2n>
just throwing that out there
aeth has quit [Ping timeout: 240 seconds]
<sm2n>
the other kind of improper list can be handled by looping and checking the type of (rest list)
<Alfr>
bollu, there's DESCRIBE and INSPECT.
<Alfr>
bollu, also *PRINT-CIRCLE* defaults to NIL.
<Alfr>
bollu, so you have to turn it on when you want to rely on printing to show you things.
taiju has quit [Ping timeout: 240 seconds]
aeth has joined #commonlisp
<bollu>
Alfr mh, okay
<bollu>
alright, thanks a lot for all the help! I'm off to bed now