Josh_2 has quit [Quit: ERC (IRC client for Emacs 26.1)]
Posterdati has quit [Ping timeout: 246 seconds]
Posterdati has joined #lisp
ricekrispie has quit [Read error: Connection reset by peer]
ricekrispie has joined #lisp
orivej has quit [Ping timeout: 272 seconds]
ricekrispie has quit [Read error: Connection reset by peer]
ricekrispie has joined #lisp
ricekrispie has quit [Read error: Connection reset by peer]
sjl has quit [Ping timeout: 272 seconds]
elderK has quit [Ping timeout: 245 seconds]
wigust has joined #lisp
wigust- has quit [Ping timeout: 268 seconds]
rumbler31 has joined #lisp
ricekrispie has joined #lisp
orivej has joined #lisp
anewuser has joined #lisp
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
troydm has joined #lisp
z3t0 has joined #lisp
orivej has quit [Ping timeout: 258 seconds]
xkapastel has quit [Quit: Connection closed for inactivity]
<ck_>
Good morning
<LdBeth>
Morning
q9929t has joined #lisp
q9929t has quit [Quit: q9929t]
dddddd has quit [Remote host closed the connection]
notzmv has quit [Ping timeout: 268 seconds]
ricekrispie2 has joined #lisp
beach has joined #lisp
ricekrispie has quit [Ping timeout: 245 seconds]
<beach>
Good morning everyone!
bexx has joined #lisp
<ober>
morning beach
karlosz_ has joined #lisp
Bike has quit [Quit: Lost terminal]
derrida has left #lisp ["WeeChat 2.6-dev"]
ym555 has quit [Quit: leaving...]
ebrasca has quit [Remote host closed the connection]
bexx has quit [Remote host closed the connection]
vlatkoB has joined #lisp
gravicappa has joined #lisp
_whitelogger has joined #lisp
nanoz has joined #lisp
karlosz_ has quit [Quit: karlosz_]
fiveop has quit []
mindthelion has joined #lisp
techquila has quit [Read error: Connection reset by peer]
torbo has quit [Remote host closed the connection]
mindthelion has quit [Ping timeout: 252 seconds]
techquila has joined #lisp
orivej has joined #lisp
techquila has quit [Ping timeout: 250 seconds]
mathrick has quit [Ping timeout: 252 seconds]
techquila has joined #lisp
mathrick has joined #lisp
sveit has joined #lisp
simplegauss has joined #lisp
orivej has quit [Ping timeout: 258 seconds]
libertyprime has quit [Ping timeout: 245 seconds]
mathrick has quit [Ping timeout: 250 seconds]
mathrick has joined #lisp
mulk has quit [Ping timeout: 272 seconds]
dale has quit [Quit: dale]
mathrick has quit [Ping timeout: 250 seconds]
elderK has joined #lisp
mathrick has joined #lisp
beach has left #lisp ["ERC Version 5.3 (IRC client for Emacs)"]
Lord_of_Life has quit [Ping timeout: 272 seconds]
mathrick has quit [Ping timeout: 250 seconds]
Lord_of_Life has joined #lisp
mathrick has joined #lisp
justinmcp_ has joined #lisp
justinmcp has quit [Quit: No Ping reply in 180 seconds.]
mbrumlow has quit [Ping timeout: 248 seconds]
zotan has quit [Ping timeout: 248 seconds]
zotan has joined #lisp
mbrumlow has joined #lisp
Inline has quit [Quit: Leaving]
karlosz_ has joined #lisp
tumdum has joined #lisp
sauvin has joined #lisp
JohnMS_WORK has joined #lisp
karlosz_ has quit [Quit: karlosz_]
karlosz_ has joined #lisp
karlosz_ has quit [Quit: karlosz_]
amerlyq has joined #lisp
t58 has joined #lisp
schweers has joined #lisp
SaganMan has joined #lisp
JohnMS_WORK has quit [Read error: Connection reset by peer]
JohnMS_WORK has joined #lisp
mathrick has quit [Ping timeout: 252 seconds]
mathrick has joined #lisp
mathrick has quit [Ping timeout: 252 seconds]
wokko has joined #lisp
anewuser has quit [Ping timeout: 245 seconds]
elderK has quit [Remote host closed the connection]
elderK has joined #lisp
esrse has joined #lisp
pjb has joined #lisp
donotturnoff has joined #lisp
scymtym has joined #lisp
josemanu1l has joined #lisp
nanoz has quit [Read error: Connection reset by peer]
nanoz has joined #lisp
josemanu1l is now known as josemanuel
ltriant has quit [Ping timeout: 248 seconds]
nanoz has quit [Ping timeout: 258 seconds]
hhdave has joined #lisp
elderK has quit [Quit: WeeChat 1.9]
schweers has quit [Remote host closed the connection]
schweers has joined #lisp
varjag has joined #lisp
orivej has joined #lisp
keep_learning has joined #lisp
dddddd has joined #lisp
mathrick has joined #lisp
lavaflow has quit [Ping timeout: 272 seconds]
manualcrank has quit [Quit: WeeChat 1.9.1]
orivej has quit [Ping timeout: 268 seconds]
mingus has quit [Remote host closed the connection]
Josh_2 has joined #lisp
notzmv has joined #lisp
test1600 has joined #lisp
jmercouris has joined #lisp
orivej has joined #lisp
iovec has joined #lisp
libertyprime has joined #lisp
orivej has quit [Ping timeout: 248 seconds]
wilfredh has joined #lisp
igemnace has quit [Quit: WeeChat 2.5]
fivo has joined #lisp
DGASAU has quit [Read error: Connection reset by peer]
charh has quit [Ping timeout: 245 seconds]
charh has joined #lisp
wuehlmaus has joined #lisp
zaquest has joined #lisp
szmer has joined #lisp
SaganMan has quit [Ping timeout: 268 seconds]
jmercouris has quit [Ping timeout: 245 seconds]
xkapastel has joined #lisp
jmercouris has joined #lisp
JohnMS_WORK has quit [Read error: Connection reset by peer]
papachan has joined #lisp
Josh_2 has quit [Quit: ERC (IRC client for Emacs 26.1)]
JohnMS_WORK has joined #lisp
v88m has quit [Ping timeout: 258 seconds]
wokko has quit [Quit: leaving]
alexanderbarbosa has joined #lisp
Josh_2 has joined #lisp
notzmv has quit [Ping timeout: 245 seconds]
jmercouris has quit [Ping timeout: 268 seconds]
Lycurgus has joined #lisp
nowhere_man has joined #lisp
nowhere_man has quit [Ping timeout: 268 seconds]
Necktwi has joined #lisp
jmercouris has joined #lisp
orivej has joined #lisp
<phoe>
hryyy
<shka__>
phoe: ?
iovec has quit [Quit: Connection closed for inactivity]
admich has joined #lisp
nowhere_man has joined #lisp
test1600_ has joined #lisp
test1600_ has quit [Remote host closed the connection]
Bike has joined #lisp
test1600 has quit [Ping timeout: 268 seconds]
makomo has quit [Ping timeout: 248 seconds]
nowhere_man has quit [Ping timeout: 258 seconds]
<jmercouris>
how would one do something like an enum in Lisp?
<jmercouris>
I was thinking about just making a plist
<jmercouris>
I might just make a function instead though, that makes sense to me
<jmercouris>
is a function call significant overhead as compared to simply having a constant?
<jmercouris>
I ask because I'm hesitant to use a constant, as the implmentation may change, that data may end up being stored in a database rather than in a configuration file, or in the source code
<Bike>
well, yes.
<jmercouris>
now when you say "significant", how many magnitudes are we talking about here?
esrse has quit [Ping timeout: 246 seconds]
orivej has quit [Ping timeout: 248 seconds]
<phoe>
shka__: woop
<phoe>
s/r/e/
<Bike>
if your constant is an immediate fixnum, reading it will probably take zero time
<Bike>
so, infinite magnitudes i guess
<phoe>
jmercouris: you could define a pure function that accepts an argument and returns constant numbers
<LdBeth>
jmercouris: what do you want to do with enum? I think most of the time plain symbols just work
<Bike>
not that a function call is THAT expensive. but it will be more expensive. given that the operation of the function will be to look up a constant?
<phoe>
like (my-enum :apple) ;=> 0, (my-enum :banana) ;=> 1
<phoe>
and then declare it inline
jmercouris has quit [Ping timeout: 246 seconds]
<phoe>
this will inline the constant and then allow the compiler to optimize the number into raw assembly
<phoe>
which should be as fast as possible
LiamH has joined #lisp
<phoe>
if you then need to change the implementation, declare the function notinline, recompile your whole codebase, replace the function body with something that e.g. fetches data from database and returns the same numbers
<phoe>
that will obviously be slower but also more flexible
<phoe>
but the question is, do you absolutely need numbers in there? maybe keywords can be enough
nowhere_man has joined #lisp
<schweers>
The question is also: how often will this function be called? If it’s not in a tight loop my guess would be that you don`t have to worry about it.
<schweers>
Even if you need it in a tight loop, just bind a variable outside (it’s supposed to be constant anyway, right?)
slac-in-the-box has quit [Remote host closed the connection]
eschulte has quit [Quit: leaving]
orivej has quit [Ping timeout: 245 seconds]
saravia has joined #lisp
saravia has quit [Ping timeout: 248 seconds]
<aeth>
The StackOverflow answer seems mostly correct, except for using symbols instead of keywords, which the top comment addresses. Obviously, you might need to use the number-based more-enumlike solution in some cases (FFI, databases, network, etc.) in which case I usually just name constants. They can still be namespaced with separate packages.
<aeth>
Sometimes I use structs with typed slots or with array backing, which won't be as efficient since there's a runtime lookup, but they should still be pretty efficient. And with with-accessors, you don't really notice they're accessors, not variables.
<aeth>
You could probably do the accessor lookup at compile time via a macro.
igemnace has joined #lisp
schweers has quit [Ping timeout: 250 seconds]
<pfdietz>
Just use keywords. Usually no need to encode values as integers.
Josh_2 has quit [Ping timeout: 246 seconds]
lnostdal has quit [Quit: "Fascism, Nazism, Communism and Socialism are only superficial variations of the same monstrous theme—collectivism." -- Ayn Rand]
aedb has joined #lisp
shka_ has joined #lisp
NickBusey has joined #lisp
iovec has joined #lisp
jmercouris has joined #lisp
m00natic has joined #lisp
varjag has quit [Quit: ERC (IRC client for Emacs 25.2.2)]
linack has joined #lisp
kajo has quit [Ping timeout: 258 seconds]
linack has left #lisp [#lisp]
Necktwi has quit [Remote host closed the connection]
lnostdal has joined #lisp
alexanderbarbosa has quit [Remote host closed the connection]
alexanderbarbosa has joined #lisp
lavaflow has joined #lisp
steadshot has quit [Remote host closed the connection]
orivej has joined #lisp
cosimone has joined #lisp
orivej has quit [Ping timeout: 268 seconds]
rippa has joined #lisp
sjl has joined #lisp
makomo has joined #lisp
FreeBirdLjj has quit [Remote host closed the connection]
Josh_2 has joined #lisp
amerlyq has quit [Quit: amerlyq]
m00natic has quit [Remote host closed the connection]
aedb has quit [Ping timeout: 272 seconds]
orivej has joined #lisp
jmercouris has quit [Remote host closed the connection]
orivej has quit [Ping timeout: 248 seconds]
hhdave has quit [Quit: hhdave]
v88m has joined #lisp
themsay has quit [Read error: Connection reset by peer]
themsay has joined #lisp
paul0 has joined #lisp
makomo has quit [Ping timeout: 272 seconds]
Josh_2 has quit [Read error: Connection reset by peer]
Lycurgus has quit [Quit: Exeunt]
lnostdal has quit [Ping timeout: 268 seconds]
cosimone has quit [Ping timeout: 258 seconds]
cosimone has joined #lisp
lucasb has quit [Quit: Connection closed for inactivity]
DGASAU has joined #lisp
igemnace has quit [Read error: Connection reset by peer]
Lord_of_Life has quit [Ping timeout: 245 seconds]
Lord_of_Life has joined #lisp
iovec has quit [Quit: Connection closed for inactivity]
nowhere_man has joined #lisp
cosimone has quit [Ping timeout: 252 seconds]
nanoz has joined #lisp
cosimone has joined #lisp
scymtym has quit [Ping timeout: 252 seconds]
cosimone has quit [Ping timeout: 252 seconds]
cosimone has joined #lisp
Necktwi has joined #lisp
nowhere_man has quit [Ping timeout: 258 seconds]
themsay has quit [Ping timeout: 245 seconds]
lnostdal has joined #lisp
themsay has joined #lisp
aedb has joined #lisp
cosimone has quit [Ping timeout: 252 seconds]
cosimone has joined #lisp
themsay has quit [Read error: Connection reset by peer]
themsay has joined #lisp
Josh_2 has joined #lisp
simendsjo has joined #lisp
cosimone has quit [Ping timeout: 252 seconds]
varjag has joined #lisp
sauvin has quit [Read error: Connection reset by peer]
cosimone has joined #lisp
simendsjo has quit [Quit: ERC (IRC client for Emacs 26.2)]
cosimone has quit [Ping timeout: 252 seconds]
aedb has quit [Ping timeout: 258 seconds]
nolanv has quit [Ping timeout: 245 seconds]
simendsjo has joined #lisp
solrize has joined #lisp
iovec has joined #lisp
warweasle has quit [Quit: soon]
rippa has quit [Ping timeout: 244 seconds]
aindilis has joined #lisp
sjl has quit [Quit: WeeChat 2.3-dev]
rippa has joined #lisp
actuallybatman has joined #lisp
v88m has quit [Read error: Connection reset by peer]
v88m has joined #lisp
gravicappa has quit [Ping timeout: 246 seconds]
donotturnoff has quit [Ping timeout: 246 seconds]
Bike_ has joined #lisp
Bike has quit [Ping timeout: 256 seconds]
cosimone has joined #lisp
phadthai has quit [Quit: reboot]
phadthai has joined #lisp
sjl has joined #lisp
<cosimone>
hello everyone, basic newb question: i am currently reading about the CLOS for the first time, and apparently, it looks like defstruct is still in the language for the sake of backwards compatibility
<cosimone>
are there stil valid use cases for defstruct even in current code, or can i just go ahead and use defclass all the time?
<TMA>
cosimone: yes and yes.
<solrize>
defstruct is nicer bc it makes the accessor funcs for you etc
<Bike_>
defstruct can be more efficient sometimes, but you should basically always use defclass.
Bike_ is now known as Bike
<Bike>
especially if you don't know what you are doing.
<solrize>
hmm
<solrize>
ok i defer to bike
<solrize>
but istm that defclass needs more boilerplate
<cosimone>
i don't want to bother with what is efficient or not early on
<Bike>
if you like defstruct's automatic symbol choices you could use a macro around defclass.
<TMA>
solrize: there are things like defclass* / define-class libraries that provide the conveniences of defstruct
<Bike>
indeed you don't.
<cosimone>
from what i've seen, isn't providing an :accessor symbol to a slot enough to get nicer reader-writer functions?
<TMA>
cosimone: there are use cases (like treating lists/arrays as structures) that defclass does not provide
<cosimone>
hell, it seems even better than the default structname-slotname names generated by defstruct
<cosimone>
TMA: uhm, such as?
<solrize>
i really should read a clos tutorial sometime. i looked at it once and went this is too complicated
<Bike>
solrize is saying that sometimes having to specify all the :accessors and stuff can be repetitive.
<TMA>
cosimone: indeed, it is sufficient to provide the :accessor
<jasom>
CL has several pairs that are static/fast and dynamic/not as fast; structures and classes are one of these
<cosimone>
i agree though, that defstruct looks more "compact" if you don't need anything fancy
<jasom>
unless you know that the overhead of classes will cause problems, I don't see a reason to use structures
bexx has joined #lisp
<cosimone>
at first glance, i'd just use classes by default and then change to structs if absolutely necessary for performance
<Bike>
yeah, pretty much.
<cosimone>
honestly, worrying about stuff like this early seems like a textbook example of premature optimization
varjag has quit [Ping timeout: 258 seconds]
<dlowe>
also, you will hate it if you ever want to add or remove a field to a struct without restarting
<dlowe>
and you will
<TMA>
cosimone: you probably don't need that now, or ever
<cosimone>
ok, it all makes sense
<cosimone>
does any of you have an example where structs could be preferred for reasons other than pure performance?
<dlowe>
if you had a theoretical lisp implementation that didn't support the metaobject protocol, you could use a list-based struct to iterate over its contents.
<jasom>
cosimone: the only thing I can think of is that it communicates to the reader that the type is limited to the features that structures have.
<dlowe>
in practice, if it doesn't support MOP you should use a different implementation
shka_ has quit [Ping timeout: 245 seconds]
<cosimone>
jasom: i see
<jasom>
cosimone: that's a bit of a weak reason, fwiw. Also I use structures most of the time because of habit.
<jasom>
I'm not suggesting you pickup that habit though.
orivej has joined #lisp
Lycurgus has joined #lisp
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<cosimone>
jasom: i mean, i can understand why. at first glance, it seems like a reasonable choice if you aren't using methods
<aeth>
structs are useful when the :type in slots is useful because they give the compiler a lot more room for optimization. So if you're storing a single-float or an array of single-floats, you'll (in a properly optimized implementation) get faster accessors and save yourself a bunch of type declarations.
<jasom>
cosimone: you can use methods with defstruct
simendsjo has quit [Ping timeout: 245 seconds]
<cosimone>
oh
nanoz has quit [Ping timeout: 272 seconds]
<aeth>
In practice, if you wanted to use :type in defclass slots, well, you shouldn't, because implementations can freely ignore it, and the most popular implementation (SBCL) does ignore it on default optimization levels so the vast majority of your users won't ever get type checking. You'd have to use the MOP to ensure types get checked.
<aeth>
So I guess some people with heavily typed slots might use structs even if not for performance, especially if they mainly care about type checking in SBCL, where structs will get their slots typechecked but standard objects won't.
<aeth>
But that's not really a good reason because that's just an SBCL-first development approach when you can just portably use the MOP
<aeth>
Most of CL's weaknesses in general revolve around when you *don't* want to be generic. Basically the anti-Go.
<aeth>
But, anyway, what you then wind up with is basically a split, and one of the few actual uses of defstruct. If you want to reliably check slot types, use a metaclass in defclass to ensure that e.g. ":checked-type" is always checked via an assert. If you want an implementation to be able to optimize based on provided slot types, use defstruct.