freenode/#lisp - IRC Chatlog
Search
15:56:34
lukego
beach: so the Erik Naggums of the world keep telling me, but I don't believe it's as black and white as that.
15:57:32
beach
lukego: In practice, not every slot should have an :INITFORM, not every slot should have an :INITARG, not every slot should have a :READER, and not every slot should have a :WRITER.
15:57:57
lukego
to me it sounds like saying that Java class definitions are only verbose if you don't care about scope, mutability, and allocation policy. but that doesn't excuse typing "public static final ..." ten thousand times
15:59:17
jmercouris
lukego: here is an example of us using it: https://github.com/atlas-engineer/nyxt/blob/master/source/blocker-mode.lisp
15:59:51
lukego
jmercouris: thanks! I'll try joining you at the philistines table and see how I fit in :) but I am guessing that reading AMOP will change my idea of what is appropriate, for better or worse, and I don't know in what direction
16:00:36
beach
jmercouris: Yes, it is no doubt quite convenient... if you don't care about modularity and consistent protocols, like I said.
16:00:46
lukego
beach: I'm often just creating internal data structures and not public interfaces. the way in other languages one might use a throw-away dictionary or tuple.
16:02:55
beach
lukego: Even for those, it pays off to think about what kind of options you want to give to MAKE-INSTANCE, what slots you want to be writable, etc.
16:03:47
jmercouris
If Encapsulation is important, you’ll end up writing getters and setters anyways
16:04:39
jmercouris
Talking about using class instances as a way to pass state around , instead of thinking about them as objects
16:09:46
beach
In particular, you may not want to use :ACCESSOR if you want client code to read the slot, but not write it.
16:10:49
mfiano
I even go as far as to define a %-prefixed accessor in addition to a reader that is exported, rather than use slot-value for internal code, since it is often wanted to extend that protocol
16:12:57
mfiano
If I don't want users to write, I'll export a symbol used for :reader, and give myself a non-exported symbol for :accessor/:writer
16:13:22
jackdaniel
howerver given that you bother to write down how to use your system and you do not mention the writer (setf foo), then if someone uses it then it is violating the library protocol
16:14:16
lukego
This may shock you guys but I sometimes even pass around data as *lists of atoms* :)
16:14:18
beach
jackdaniel: Sure. But it is good to give warnings or errors in case of incorrect use.
16:16:00
mfiano
It surprises me at how many codebases use the same symbol name for the slot as the accessor (in the general sense, not :accessor)
16:16:13
jackdaniel
beach: I tentatively agree but one could consider adding (setf %extra) accessors clobbering from the code perspective (and one more sub-protocol to keep in mind when working on the system)
16:17:52
pve
lukego: you might use emacs to generate an initial defclass form for you, and then edit as necessary
16:17:52
lukego
The whole "ravioli code" concept with layers of empty calories between every tiny morsel of meat :)
16:19:21
pve
you end up with a defclass form that everyone understands, without having to type it all out
16:19:50
lukego
This is the big challenge with CLOS for me. I don't /want/ to agree with what you guys are saying :) I like the kind of Lisp code that Peter Norvig writes and he's more likely to use DEFCLASS with :TYPE LIST than any of this business
16:22:03
lukego
but maybe it is more of an applications verses libraries thing. I'm writing code that I expect to churn quickly and not be seen by anyone else's eyes before being rewritten a couple of times. so it doesn't seem rational to spend time worrying about how a hypothetical unknown third party might interact with this code. different situation if you're pushing libraries to github/quicklisp.
16:24:04
jmercouris
All of the advice so far has been given within the context of third party consumers and some robust foundation
16:25:42
lukego
I can also understand that if you spend time teaching people to program in Lisp, you will want to be focusing on the best practices for doing this properly, since people can always use their judgement to take shortcuts later.
16:26:28
lukego
I'm reading some ACL2 code that has page-long definitions on which each line is of the form (defun foo-quux (foo) (caddddddddddr foo))
16:26:51
Xach
there's also a big difference between "there's no reason for [the way defclass works]" and "i don't like how it works" or "the problems that it solves aren't that important to me" etc
16:26:58
beach
jmercouris: I am saying that DEFSTRUCT is already a way to make your code more modular and with defined protocols. If you don't think you need such things, there might be no point in using DEFSTRUCT either. Lists could be more flexible.
16:27:09
lukego
so even for throw-away code I appreciate easy ways to get accessors, places to hang print functions, etc.
16:28:17
lukego
beach: that's a good point. in other languages I would do exactly that e.g. if they have pattern matching to make it convenient. could well be that in serapeum there are such facilities and some of my structs could be lists because I don't need dedicated accessor functions.
16:28:41
Bike
i wish structure objects were defined with defclass, and defstruct was a library macro to define accessors with convenient names
16:28:48
lukego
ACTION makes mental note to read some idiomatic serapeum code e.g. implementation of serapeum itself
16:30:05
jackdaniel
Bike: in the vast undefined behavior (defclass foo () () (:metaclass structure-class)) works on some implementations
16:31:19
splittist
mixins and generic functions are a great way to allow for unforeseen behaviour modification. And every time I worry about performance I tell myself the world now runs on javascript over the network.
16:31:27
lukego
Gnuxie[m]: I do a lot of rewriting. I'll probably rewrite all this particular code at least a couple of times before I share it with anyone else. I've already rewritten much of it once.
16:31:29
Bike
you'd probably have to do something funky to ensure the class is defined at enough at compile time to allow subclassing
16:32:09
jackdaniel
ah, that's it, I've tried redefining foo, when I define a "fresh" class, then I can put slots in there
16:33:19
Bike
defstruct has to do funky stuff of that kind. defstruct is kind of entirely funky stuff
16:35:18
pve
lukego: I once worked on an old application that stored everything (or a lot, anyway) in symbol plists. A curious design choice, but it did work..
16:36:06
lukego
pve: thank you for normalizing the use of whatever quirky representation one prefers in the privacy of one's own codebase :)
16:36:32
Xach
If your program does something very useful, people will often adapt to it, rather than demand vice versa
16:37:03
mfiano
THat's a major problem with Lisp. People often care more about the code than the artifact
16:38:14
Xach
It's a problem with many forms of endeavor - obsession with the tools and their proper use rather than the product of the tools. But there's no denying that a nice tool, used properly, is a delight.
16:38:36
lukego
I'll admit that I allow myself to spend much more creative energy on editing Lisp code than most other languages. I enjoy that though. keeps me amused while I'm programming
16:38:45
Xach
ACTION thinks of people who post pictures of their workbench and planes rather than the useful objects produced with them
16:39:04
Shinmera
I hate my level editor a whole lot, but simply don't have the time to make it nice.
16:40:15
pve
lukego: but to be fair, it was written mostly by computational linguists who only wanted to get the job done
16:41:12
Shinmera
Well the most pressing deadline is me running out of money, so I have to be very smart with that.
16:41:36
Shinmera
Other than that we also have a release schedule we're aiming for, which is roughly 2 years from now.
17:13:42
_death
jackdaniel: I'm surprised ;).. I expected some resistance, at least for the draw-arrow stuff, if not the keybindings (which I supposed must have had some good reason not to be there in the last 20 years)
17:17:40
_death
jackdaniel: cool :).. I also had to patch the coordinates stuff, which currently has exact comparisons incl. on floats that causes trouble with ellipses, but I noticed the commented version and some old mcclim-devel discussions and some issues on github so I thought another approach may be on the queue
17:18:38
jackdaniel
I want to change the ellipse representation from parralelogram to something more stable (transformation-wise)
17:19:20
_death
yeah, that's one of things I gathered.. the exact comparisons may caused issues elsewhere too
17:19:58
jackdaniel
comparisons are one issue, but the current code can error because of a non-reversible transformation (due to rounding errors)
17:21:09
_death
right.. there are two issues.. the inversion is easy to reproduce with the Fig example, and the comparison is easy with https://www.artm-friends.at/rm/kytron/kytron-clim.html (after small tweaks to make it work)
17:30:21
_death
I also have some changes to scigraph, but it may be that it doesn't work right only for me.. I guess the most annoying issue right now is the repeated mapping and unmapping (with lots of match error 42) that happens if I switch windows in stumpwm, usually once per application frame.. also, (setf clim:*default-server-path* :clx) looks cool and retro :)
17:33:47
_death
(to make clear, this issue is not limited to scigraph.. it often happens with any arbitrary application frame)
18:36:18
albusp
Trying to get sly working with emacs, currently I don't have slynk running (no lisp process active), and indenting code in *.lisp files gives the error "Symbol’s function definition is void: sly-common-lisp-indent-function". I'm checking sly.el and others, and found a line in slynk.lisp mentioning the function: https://github.com/joaotavora/sly/blob/e927cdae984b2c3383e1e2358e37f1a4115b142e/slynk/slynk.lisp#L3996.
18:37:55
albusp
slynk is not yet running because it doesn't compile on abcl (yet - i'm trying to fix it)
19:06:26
contrapunctus
"Who needs DEFSTRUCT anyway. You can just use CAR/CDR." lol I had to do a double take here, until I read the previous message 😄
20:00:14
aeth
Everyone comes into Common Lisp for different reasons so there's no real one true way to represent something. If you really wanted to just use conses for everything, though, CL isn't really the right language for that because they're not optimized. (destructuring-bind is a very nice macro for handling conses, though)
20:30:18
aeth
I guess that is equivalent, but it seems less readable to me than the more verbose (let ((*print-case* :downcase)) (format nil "~A" 'foo))
20:32:33
aeth
I go back and forth between loving FORMAT and hating FORMAT so I'll probably use it in the future
22:06:55
no-defun-allowed
jmercouris: I think that if the result of evaluating X and X are equivalent, then you are saying that every evaluation has a fixed point.
22:07:56
no-defun-allowed
That could be the case in e.g. Miranda or Haskell, as e.g. [x, y :: z] could evaluate to [1, 2, 3] which evaluates to [1, 2, 3] but not any Lisp.
22:10:19
no-defun-allowed
If it were, then e.g. X should always evaluate to 'X. I won't make an example for transitivity.
22:17:12
no-defun-allowed
So it would be evident why "equivalent" has a particular meaning when used in the context of Lisp evaluation?
22:26:58
no-defun-allowed
(Actually, that is probably not even the case in Haskell or Miranda. We might say 2 and 1 + 1 are equivalent forms, but an evaluator for one of those languages might reduce 1 + 1 to 2, but not the other way around.)
22:29:39
sm2n
blah blah referential transparency, they are equal within the denotational semantics of the language
22:30:37
sm2n
in pure fp things are given their identity by their normal form under reduction, by church-rosser or related
22:56:16
phantomics
Hey all, wondering if there's a library that converts HTML-encoded characters like " to Unicode. Tried some HTML parsers that didn't do it and can't see anything to do it on CL package lists
23:13:56
raeda
The numeric encoding is the code point number iirc. SBCL has unicode lookup by code point and you might be able to use CL-PPCRE to find & replace
23:41:46
moon-child
no-defun-allowed, sm2n: no denotational semantics required, you can define equality strictly in terms of halting
23:43:07
moon-child
given two expressions e1 and e2 in some language L, consider the universe of hole-containing programs within L. For each of those programs, substitute each of e1 and e2 for the hole. If there's any case when e1 causes a halt and e2 does not (or vice versa) then the expressions are not equivalent
23:53:51
no-defun-allowed
This is somewhat more interesting than arguing that EVAL is not an equivalence relation.
1:18:30
sm2n
moon-child: what about a language like idris where all well-formed programs are guaranteed to halt?
1:21:43
moon-child
I don't think that definition is usually applied to non turing-complete languages
1:23:39
moon-child
the advantage of that definition is that it works for all turing-complete languages without needing to have any knowledge of their semantics beyond that
1:30:59
sm2n
or actually, moon-child, do you happen to have a reference that discusses this? I'd like to read more about it
3:13:12
lukego
Thanks everyone for the rigorous discussion of datatype definition styles yesterday. I reread the Serapeum docs from beginning to end to try and update my mental model. For really ad-hoc internal data structures I need to experiment with DICT/MATCH and with DEFUNION.
3:18:59
lukego
Maybe DEFCLASS verses DEFCLASS-STD (etc) is a false dichotomy and really there are a lot of different contexts for defining datatypes that each call for a separate mechanism. kinda like IF and WHEN and UNLESS and so on.
3:19:54
lukego
I notice though that all this obsessing about how to define datatypes has not actually caused my broken program to start working and maybe I should try a different approach to that problem...
3:40:43
beach
I completely misunderstood the context and thought lukego and jmercouris were talking about the use of these operators in more-or-less final code, but it became clear that they meant the use in code that is highly likely to change, to be rewritten, or to be deleted entirely.
3:41:57
lukego
beach: I am feeling less provoked by your "if you don't care about X" comments when I read that as "when you are not immediately concerned about X in your present context" rather than "when you are a bad person because you don't give X due respect" :)
3:43:21
beach
lukego: Sure, that's a good interpretation in your case. Not so with many others who come here and who have no idea about elementary software engineering.
3:44:11
no-defun-allowed
fiddlerwoaroof: Yes, you're supposed to use generic functions, i.e. no defun. Cancel out the two negatives, and you have only fun.
3:44:40
lukego
it's a new revelation to me now though that there are a bunch of other macros, e.g. DEFCONSTRUCTOR from Serapeum, that actually capture the context i.e. that is something that you only use for a quick and simple local representation of immutable structures.
3:45:33
fiddlerwoaroof
And, what I've noticed, is that almost all "functional" programming languages use constructs that are OOP in CLOS's sense
3:46:08
fiddlerwoaroof
Clojure's multimethods are just a bad version of CLOS and Haskell has typeclasses everywhere, which basically are a compile-time version of generic dispatch
3:46:15
lukego
and that puts me off defclass-std as being "yet another defclass" rather than something complementary that's tailored to a more specific use case.
3:46:47
beach
fiddlerwoaroof: You must have missed the general consensus here in #lisp that you should avoid generic functions since they are bad for performance.
3:48:45
lukego
I liked splittist's comment that the rest of the world is built in Javascript these days so there's nothing particularly indulgent about using all the generics and indirections you please. Chrome has reset the bar on what is appropriate resource utilization by software and we can all rejoice in our relative thrift :)
3:49:42
fiddlerwoaroof
Like, I think it's probably hard to right a compiler for a dynamic language that comes close to V8
3:49:51
beach
lukego: Facts like that don't seem to prevent eternal discussions about performance. Not to mention the size of executables.
3:51:18
lukego
fiddlerwoaroof: so much the better :) writing slow code is contributing to computer science by stimulating compiler research, just look at javascript...
3:51:35
fiddlerwoaroof
The great thing about CL is that I find I can just write CL in most situations where I'd use FFI in Python
3:51:48
fiddlerwoaroof
Not to mention actually being able to benefit from multiple threads of executin
3:52:32
beach
The more I hear about Python (the language) the more I think it's a joke, and the more I am totally baffled why anyone would want to use it.
3:53:27
fiddlerwoaroof
Also, it's relatively quick to go from nothing to a proof of concept in Python
3:54:40
lukego
I like that "I must program as inefficiently as possible" mantra. that it's healthy mental exercise to burn CPU cycles and you should strive to do it as much as you can get away with.