Aruseus has quit [Remote host closed the connection]
ebrasca has quit [Remote host closed the connection]
<vms14>
aeth: sorry I was afk
<vms14>
sure it was me who mentioned about format and char arrays
<vms14>
I just love the fact you can have multiple buffers and the power of format in them
fortitude has joined #lisp
makomo_ has quit [Ping timeout: 244 seconds]
torbo has quit [Remote host closed the connection]
semz has quit [Ping timeout: 264 seconds]
<kilimanjaro>
what's the consensus on catch/throw
<kilimanjaro>
i want to have a non-local exit for a procedure and i'd just normally use `return-from` but i'd like to break things up into a few subroutines for readability
<kilimanjaro>
a few distinct top level defuns, i mean.
<aeth>
I haven't seen that used before, but I'm not sure why.
iarebatman1 has quit [Ping timeout: 245 seconds]
anewuser has joined #lisp
semz has joined #lisp
semz has quit [Changing host]
semz has joined #lisp
_whitelogger has joined #lisp
khisanth_ has quit [Ping timeout: 244 seconds]
vms14 has quit [Quit: WeeChat 2.3]
khisanth_ has joined #lisp
milanj has quit [Quit: This computer has gone to sleep]
ltriant has quit [Ping timeout: 246 seconds]
xkapastel has quit [Quit: Connection closed for inactivity]
Jeanne-Kamikaze has joined #lisp
pierpal has quit [Quit: Poof]
pierpal has joined #lisp
igemnace has quit [Quit: WeeChat 2.5]
thesorton has quit [Quit: parting]
X-Scale has quit [Ping timeout: 268 seconds]
jeosol has joined #lisp
<jeosol>
Good morning
thesorton has joined #lisp
<jeosol>
In my bid to improve code design for clarity, maintainability, and extension, I try to think of better design so subsequently added codes are progressively better. That being said, I have some CLOS design question I'll like to discuss here.
<jeosol>
I'll use a simple analogy so as to focus on the main design issues.
<jeosol>
Let's say I want to write a program to optimize a car and I can optimize some aspects of the car, e.g., the type (sedan, SUV, ...), tire size (e.g., 20-inch, 22-inch, etc), number of seats (2,4,6), etc. The options (combinations) can be large but countable.
<White_Flame>
"subsequently added code" is always a problem
<jeosol>
So I want to design a CLOS class with goals stated earlier. I can construct one massive class (defclass optimize-car-type-tire-seat () ...) and have a bunch of slots
<jeosol>
but I will prefer to have it broken down into small units (classes) with the inheritance. So a user may say they want a sedan (for type), 20-inch tire size, but not sure about the seat. I can then create the instantiate the correct object where only the number of seats will be a variable
<White_Flame>
I don't think that is a good fit for inheritance
<jeosol>
and then the optimal condition is determined from the optimization. I apologize if this is not clear, but
<White_Flame>
you have a bag of information about a car, some specified, maybe some not
aindilis has quit [Remote host closed the connection]
<White_Flame>
and you have a list of information that needs to be completed in order to consider the car complete
<jeosol>
This is not the exact problem per say, but hoping it will fit.
<White_Flame>
what sort of optimization strategy are you looking at?
<jeosol>
oh ok. it is a simple optimization problem, i imagine the car analogy was poor, if let's say, the tire was the variable in the above case. We then optimize for the tire size of thread based on the performance of the car in a given environment
<White_Flame>
optimize how? hill climbing? genetic algorithm? depth-first exhaustive search?
<jeosol>
oh, ok. Ii see you want detail. It's stochastic optimization, GA, PS, etc. The actual technique is not the problem, but the idea is to be able to gather as much information and automatically determine what to optimize based on what the user has selected
<White_Flame>
well, the data representation might be more useful depending on how the optimization is
<White_Flame>
if you know that you have a fixed set of slots, then I would allow NIL in each to simply indicate whether it "has a value" or not, to the code
<White_Flame>
as a simple class (or even struct)
<White_Flame>
the annoying thing is that you have to check all pertinent slots for non-NILness to see if you've found enough stuff
<White_Flame>
however, if you have temporary values in those slots that you're searching through, then you might want a separate state indicator for each slot
<White_Flame>
and that sort of thing does get kind of annoying with forcing everything OO, and you might want more simple data structures
<jeosol>
I just pulled out my Sonja Keene book, and the closest example is the make-stream example (defun make-stream (device-type direction element-type name) ...) and there is a function (select-stream-class direction element-type device-type) which essentially determines the right stream class to create and creates the correct instance
<White_Flame>
is that an optimization problem though?
aindilis has joined #lisp
<jeosol>
I agree with your comments White_Flame. I have a case that works but the derived cases (possible options) are becoming large to manage. The whole setup runs, but I am thinking may be the one large class, with appropriate slots and if something is nil, then it's not to be optimized. This option seems more manageable
<jeosol>
No it's not, I am trying to abstract the problem such that I can create the right class, and default the other parameters (based on other inputs the user will also specify).
<White_Flame>
is the search state inherently part of the class's data?
<White_Flame>
I would think that would reside in whatever the optimization loop is, and the instance simply being the current data point for testing fitness
<jeosol>
So, class provides contains the settings for initializing the variables for optimization. So in the example I had above, you can have a case with multiple different car scenarios (optimizing car type, car size, ...) in the same optimization run
ltriant has joined #lisp
<jeosol>
With the single, massive class, you will have to process the results to figure out which type/scenario it was, but if I had the right classes to start with, I can tell from the class, and that can be used for subsequent step or optimization.
<White_Flame>
again, this doesn't sound like classes & inheritance should be the goal here
<jeosol>
really?
<White_Flame>
you have a list of key/value pairs, and each has some initialization state, some range of values to search over (presumably), and the entire set should be able to be tested & manipulated regardless of what the overall set of slots are
<White_Flame>
that sound like a bag, not a structure
<White_Flame>
*sounds
<White_Flame>
if you want to change the number of slots, that would be a pretty heavyweight change with classes, and scanning the slots
<jeosol>
hmm, guess, I am not explaining things clearly. The operations performed on the object during the optimization depends on the class, that's why I go that route. I define some defmethods on base classes.
<White_Flame>
that still sounds like a bag of CLOS objects, each representing a searchable value with its own definitions
<White_Flame>
but yeah, I don't know enough about the problem
<jeosol>
Yes, your option is having one defclass class and just search the slots
anewuser has quit [Quit: anewuser]
<White_Flame>
there's a term I use for Java programming style. I call it "Object Obsessed" ;)
<jeosol>
I agree with that, my point was for one of flexibility in code design. I have a few cases with inheritance for other problems with 2 or 3 levels/options. But here it is may be too much because of the number of options
<jeosol>
White_Flame, I am not actually, CLOS does fit the other aspects of the code I was writing very well (:before, :around, :after methods), I don't use it everywhere though.
<jeosol>
Anyway, I appreciate your time and suggestions.
<jeosol>
That's the repo for the application I am working on. It's a fairly large code base and careful code design was important to be able to manage it so far
nullnullnull has joined #lisp
<White_Flame>
sure, but it's impossible to avoid technical debt
<White_Flame>
sometimes it is more flexible and forward-compatible to use the dynamic properties of the language
<White_Flame>
I mean, it does need to dispatch on each individual adjustable value, that's well suited to defmethod on the class of the value
<nullnullnull>
in SBCL: how to get args and save them into integer variable?
<White_Flame>
but it sounds like your main question is how to aggregate those adjustable values together, and that's where a looser dynamic data structure would work
<White_Flame>
jeosol: my strong preference would be a simple list/array/hashtable
<White_Flame>
however, there might be optimization benefits to using a class, depending on if you're CPU-bound
<jeosol>
hmm, but managing the additional functions for those cases will be harder to manage? you don't think.
<White_Flame>
well, it depends on where the work is focused. If the fitness function is massive, then you should optimize access of the values
<nullnullnull>
White_Flame, yes mate
<White_Flame>
if the mutation is the more complex part, then treating the aggregate as a simple collection makes it much easier to walk through your values to adjust
<jeosol>
the function evals are expensive, but the design considerations is one of ease to be able to change optimizations, or run optimization with one setting, and use conditions from one class into another seamlessly. The choice is also to simplify the search process
<nullnullnull>
White_Flame, thanks :) I will check
glamas has joined #lisp
<White_Flame>
you also might be better served in creating a small DSL for this, to allow you both to represent all the bits easier, as well as be able to output precise code that runs dedicated to each value
<White_Flame>
it sounds like you're working with templates and option sets
<White_Flame>
but trying to inherit them instead of referring to them
<White_Flame>
a DSL can unpack & combine all that for you
<jeosol>
That's true. I asked something related and similar to this, and Dim Fontaine (?) suggested a DSL and writing some reader to take in simplify input and map accordingly.
<White_Flame>
yep
<jeosol>
The issue is managing the many options and combinations, and also take advantage of some operations created for the base classes.
<jeosol>
Another analogy for the use case is: one needs to draw an arbitrary line in space by specify two points, (x1,y1,z1) and (x2,y2,z2) and there are constraints on the line length, (e.g., length within some interval) and location in space to maximize a resource.
<nullnullnull>
btw why sbcl --eval is not working like --load? (if i put the whole script into --eval it will not load the "require" packages)
<jeosol>
One can start the search by assuming the lines are vertical so only 4 variables (x1,y1,z1,z2) with (x2=x1, and y2=y1) to fine the best part of the environments and then later relax the constraint. The latter case, the optimization for the first search has 4 variables, in the latter we could relax constraints on z1, and z2 and perform another search
<jeosol>
now with 2 variables
<jeosol>
with the others fixed or allowed to vary over small spaces. This is not guaranteed to get the global optimum, but not get quick solution.
<jeosol>
In both case, by calling a function (run-optimizer object), it will automatically perform the correct search based on what can be optimized.
<jeosol>
*cases
karswell has quit [Remote host closed the connection]
gravicappa has joined #lisp
notzmv has quit [Ping timeout: 272 seconds]
<jeosol>
White_Flame Do you have some library or resource you recommend for the example DSL you mentioned above?
karswell has joined #lisp
<White_Flame>
write one, that's the strength of Lisp :)
<White_Flame>
frameworks often make complex mountains out of small custom molehills
<White_Flame>
_especially_ when it is customization that is sought
<jeosol>
ok doki. I didn't mean the exact thing I wanted, but something like a tutorial, an example, etc.
<jeosol>
but your point is taken. Will do. I hope I can get something clean and easily maintainable towards my goal of automated systems.
<White_Flame>
across the many DSLs and data-driven systems I've written, the reason they were written was to solve a very specific representation problem with the exact problem at hand
orivej has quit [Ping timeout: 268 seconds]
Bike has quit [Quit: Lost terminal]
<White_Flame>
but you start with "How would I ideally wish to represent this?", write down some pseudocode/data/declarations, then write Lisp to transform/execute those
xivh has left #lisp ["ERC (IRC client for Emacs 26.1)"]
<jeosol>
Yeah, thanks. I googled and found a nice DSL example with CL
_Ark_ has joined #lisp
ark has quit [Read error: Connection reset by peer]
vlatkoB has joined #lisp
Jeanne-Kamikaze has quit [Remote host closed the connection]
superkumasan has quit [Ping timeout: 248 seconds]
nullnullnull has quit [Ping timeout: 246 seconds]
<beach>
Good morning everyone!
<LdBeth>
Morning, beach
pierpal has quit [Ping timeout: 272 seconds]
shka_ has joined #lisp
shka_ has quit [Ping timeout: 244 seconds]
<jeosol>
Good morning beach
<jeosol>
I am looking to get a physical copy of Cltl2
<edgar-rft>
you can make a copy on an USB stick if that's physical enough
<jeosol>
haha. Edgar. By physical I meant book. I check on Amazon, I saw 600 box for a hard cover one time, but later saw some for around $70-$90 box
<edgar-rft>
jeosol: here in europe there are also lots of online book stores selling old books from libraries. If you'e lucky you can get a copy for a few bucks.
dmiles has quit [Ping timeout: 246 seconds]
<jeosol>
edgar-rft, that is the option I was hoping for - a used copy
FennecCode has quit [Quit: ERC (IRC client for Emacs 26.2)]
makomo_ has joined #lisp
glamas_ has joined #lisp
glamas_ has quit [Client Quit]
<edgar-rft>
jeosol: I just looked at ebay and instantly found three copies below 10 bucks fom the USA, shipping costs more expensive than the book itself
chambln has quit [Quit: Quit]
<jeosol>
ok. saw the listings. These ones are cheaper
SaganMan has joined #lisp
froggey has quit [Ping timeout: 245 seconds]
froggey has joined #lisp
gxt has quit [Ping timeout: 260 seconds]
vlatkoB_ has joined #lisp
vlatkoB has quit [Ping timeout: 248 seconds]
mindthelion has joined #lisp
techquila has quit [Ping timeout: 250 seconds]
mindthelion has quit [Ping timeout: 258 seconds]
karswell_ has joined #lisp
schjetne has quit [Ping timeout: 245 seconds]
karswell has quit [Ping timeout: 258 seconds]
lnostdal has quit [Remote host closed the connection]
liberiga has quit [Ping timeout: 260 seconds]
varjag has joined #lisp
gxt has joined #lisp
ltriant has quit [Quit: leaving]
pierpal has joined #lisp
amerlyq has joined #lisp
igemnace has joined #lisp
JohnMS_WORK has joined #lisp
pierpal has quit [Ping timeout: 245 seconds]
milanj has joined #lisp
<LdBeth>
edgar-rft: there’s one line footnote exceeding the page boundary in the DVI version available
schweers has joined #lisp
SaganMan has quit [Ping timeout: 248 seconds]
lalitmee has quit [Ping timeout: 245 seconds]
dmiles has joined #lisp
schjetne has joined #lisp
maxxcan has joined #lisp
pierpal has joined #lisp
Sauvin has quit [Ping timeout: 272 seconds]
Sauvin has joined #lisp
JohnMS_WORK has quit [Read error: Connection reset by peer]
eddof13 has joined #lisp
eddof13 has quit [Client Quit]
Lord_of_Life has quit [Ping timeout: 268 seconds]
Lord_of_Life has joined #lisp
j0nd0e has joined #lisp
pdv has joined #lisp
Insanity_ has joined #lisp
pdv has quit [Client Quit]
pdv has joined #lisp
lalitmee has joined #lisp
pdv has quit [Remote host closed the connection]
dale has quit [Quit: My computer has gone to sleep]
CrazyEddy has quit [Remote host closed the connection]
orivej has joined #lisp
techquila has joined #lisp
techquila has quit [Max SendQ exceeded]
techquila has joined #lisp
milanj has quit [Quit: This computer has gone to sleep]
froggey has quit [Ping timeout: 245 seconds]
froggey has joined #lisp
maxxcan has quit [Quit: maxxcan]
j0nd0e has quit [Read error: Connection reset by peer]
j0nd0e has joined #lisp
heisig has joined #lisp
ebrasca has joined #lisp
elinow has joined #lisp
schjetne has quit [Ping timeout: 245 seconds]
schjetne has joined #lisp
scymtym has quit [Read error: Connection reset by peer]
scymtym has joined #lisp
CrazyEddy has joined #lisp
cosimone has joined #lisp
p9fn has joined #lisp
j0nd0e has quit [Ping timeout: 258 seconds]
schjetne has quit [Ping timeout: 272 seconds]
random-nick has joined #lisp
superkumasan has joined #lisp
techquila has quit [Ping timeout: 258 seconds]
schjetne has joined #lisp
manualcrank has quit [Quit: WeeChat 1.9.1]
dddddd has joined #lisp
akoana has left #lisp ["Leaving"]
nowhereman has joined #lisp
igemnace has quit [Read error: Connection reset by peer]
nowhereman has quit [Ping timeout: 258 seconds]
igemnace has joined #lisp
gravicappa has quit [Ping timeout: 258 seconds]
milanj has joined #lisp
cosimone has quit [Quit: WeeChat 2.4]
trocado has joined #lisp
shka__ has quit [Quit: WeeChat 1.9.1]
trocado has quit [Ping timeout: 258 seconds]
pierpal has quit [Remote host closed the connection]
milanj has quit [Quit: This computer has gone to sleep]
lucasb has joined #lisp
cosimone has joined #lisp
X-Scale has joined #lisp
lalitmee has quit [Quit: Leaving]
cosimone has quit [Quit: WeeChat 2.4]
j0nd0e has joined #lisp
xkapastel has joined #lisp
milanj has joined #lisp
jello_pudding has joined #lisp
LiamH has joined #lisp
trocado has joined #lisp
orivej has quit [Ping timeout: 258 seconds]
warweasle has quit [Quit: meh]
krid has joined #lisp
pierpal has joined #lisp
j0nd0e has quit [Ping timeout: 248 seconds]
<varjag>
is there anything like (ccl:current-time-in-nanoseconds) in lispworks?
<varjag>
any way to access platform's precision timer
heisig has quit [Quit: Leaving]
<dlowe>
local-time calls gettimeofday using lispworks' ffi
<dlowe>
doesn't work for windows, though
frgo has quit []
Frobozz_ has joined #lisp
Frobozz has quit [Ping timeout: 245 seconds]
Bike has joined #lisp
<varjag>
i see, thanks
Inline has joined #lisp
frgo has joined #lisp
dgfhdfg has joined #lisp
fortitude has joined #lisp
cosimone has joined #lisp
j-r has joined #lisp
j-r has quit [Changing host]
j-r has joined #lisp
sz0 has joined #lisp
makomo has joined #lisp
trocado has quit [Ping timeout: 272 seconds]
fortitude has quit [Ping timeout: 244 seconds]
makomo_ has quit [Ping timeout: 268 seconds]
cosimone has quit [Quit: WeeChat 2.4]
orivej has joined #lisp
lalitmee has joined #lisp
Frobozz_ is now known as Frobozz
mindCrime has joined #lisp
mindCrime_ has joined #lisp
mindCrime has quit [Ping timeout: 264 seconds]
iarebatman1 has joined #lisp
jello_pudding has quit [Remote host closed the connection]
maxxcan has joined #lisp
ebrasca has quit [Remote host closed the connection]
elinow has quit [Ping timeout: 244 seconds]
dale_ has joined #lisp
dale_ is now known as dale
lavaflow has joined #lisp
dgfhdfg has quit [Read error: Connection reset by peer]
ptiyoyip has joined #lisp
argoneus has quit [Remote host closed the connection]
elinow has joined #lisp
saravia has joined #lisp
dale has quit [Quit: dale]
pankajgodbole has joined #lisp
varjag has quit [Quit: ERC (IRC client for Emacs 25.2.2)]
gravicappa has joined #lisp
jeosol has quit [Remote host closed the connection]
lavaflow has quit [Ping timeout: 245 seconds]
lalitmee has quit [Remote host closed the connection]
elinow has quit [Read error: Connection reset by peer]
schjetne has quit [Ping timeout: 268 seconds]
dale has joined #lisp
dale has quit [Client Quit]
dale has joined #lisp
FreeBirdLjj has joined #lisp
cosimone has joined #lisp
igemnace has quit [Quit: WeeChat 2.5]
mindCrime_ has quit [Ping timeout: 268 seconds]
igemnace has joined #lisp
Nomenclatura has quit [Quit: q]
FreeBirdLjj has quit [Remote host closed the connection]
mindCrime has joined #lisp
FreeBirdLjj has joined #lisp
eddof13 has joined #lisp
FreeBirdLjj has quit [Ping timeout: 248 seconds]
wilfredh has quit [Quit: Connection closed for inactivity]
kiwi_49 has joined #lisp
kiwi_4937 has joined #lisp
orivej has quit [Ping timeout: 244 seconds]
kiwi_49 has quit [Remote host closed the connection]
HDurer has quit [Ping timeout: 258 seconds]
kiwi_4937 has quit [Remote host closed the connection]
kiwi_49 has joined #lisp
Aruseus has joined #lisp
orivej has joined #lisp
pepone has joined #lisp
sz0 has quit [Quit: Connection closed for inactivity]
nanoz has joined #lisp
FreeBirdLjj has joined #lisp
ptiyoyip has quit [Read error: Connection reset by peer]
pepone has quit [Ping timeout: 268 seconds]
FreeBirdLjj has quit [Ping timeout: 245 seconds]
Xach has quit [Ping timeout: 248 seconds]
Xach has joined #lisp
ntbre has joined #lisp
gxt has quit [Ping timeout: 260 seconds]
pepone has joined #lisp
nullnullnull has joined #lisp
pepone has quit [Ping timeout: 246 seconds]
<nullnullnull>
why sbcl --eval is not working like --load? (if i put the whole script into --eval it will not load the "require" packages)
paul0 has joined #lisp
xkapastel has quit [Quit: Connection closed for inactivity]
mindCrime_ has joined #lisp
mindCrime has quit [Ping timeout: 248 seconds]
nonlinear[m] has quit [Write error: Connection reset by peer]
colelyman has quit [Remote host closed the connection]
katco has quit [Read error: Connection reset by peer]
Jachy has quit [Read error: Connection reset by peer]
no-defun-allowed has quit [Read error: Connection reset by peer]
iarebatman has quit [Read error: Connection reset by peer]
sciamano has quit [Read error: Connection reset by peer]
LdBeth has quit [Read error: Connection reset by peer]
dtw has quit [Write error: Connection reset by peer]
djeis[m] has quit [Remote host closed the connection]
akanouras has quit [Read error: Connection reset by peer]
_whitelogger has joined #lisp
LdBeth has joined #lisp
rumpelszn has joined #lisp
FreeBirdLjj has joined #lisp
maxxcan has joined #lisp
Insanity_ has quit [Quit: Connection closed for inactivity]
orivej has quit [Ping timeout: 258 seconds]
pierpal has quit [Read error: Connection reset by peer]
pepone has joined #lisp
xkapastel has joined #lisp
fengshaun has joined #lisp
kiwi_49 has quit [Remote host closed the connection]
Aruseus has quit [Remote host closed the connection]
Godel[m] has joined #lisp
djeis[m] has joined #lisp
akanouras has joined #lisp
iarebatman has joined #lisp
katco has joined #lisp
Jachy has joined #lisp
colelyman has joined #lisp
sciamano has joined #lisp
eriix[m] has joined #lisp
dtw has joined #lisp
no-defun-allowed has joined #lisp
liambrown has joined #lisp
nonlinear[m] has joined #lisp
schweers has quit [Ping timeout: 250 seconds]
Xach has quit [Ping timeout: 248 seconds]
Xach has joined #lisp
lavaflow has joined #lisp
pepone has quit [Remote host closed the connection]
t58 has joined #lisp
cosimone has quit [Quit: WeeChat 2.4]
lavaflow has quit [Ping timeout: 245 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
eddof13 has quit [Quit: eddof13]
milanj has quit [Quit: This computer has gone to sleep]
iarebatman1 has quit [Ping timeout: 272 seconds]
pankajgodbole has quit [Ping timeout: 245 seconds]
nanoz has quit [Ping timeout: 245 seconds]
Nomenclatura has joined #lisp
milanj has joined #lisp
manualcrank has joined #lisp
nowhereman has joined #lisp
varjag has joined #lisp
Oladon_wfh has joined #lisp
eddof13 has joined #lisp
schjetne has joined #lisp
schjetne has quit [Ping timeout: 246 seconds]
mpcjanssen has quit [Quit: WeeChat 1.9.1]
Lycurgus has joined #lisp
gdsg has joined #lisp
nowhereman has quit [Ping timeout: 250 seconds]
nowhere_man has joined #lisp
iarebatman1 has joined #lisp
kajo has joined #lisp
vlatkoB_ has quit [Remote host closed the connection]
maxxcan has quit [Quit: maxxcan]
zotan has quit [Ping timeout: 248 seconds]
cosimone1 has joined #lisp
zotan has joined #lisp
gravicappa has quit [Ping timeout: 245 seconds]
FreeBirdLjj has joined #lisp
Lycurgus has quit [Quit: Exeunt]
FreeBirdLjj has quit [Ping timeout: 258 seconds]
Insanity_ has joined #lisp
schjetne has joined #lisp
orivej has joined #lisp
Lord_of_Life_ has joined #lisp
ggole has quit [Quit: Leaving]
LiamH1 has joined #lisp
LiamH1 has left #lisp [#lisp]
amerlyq has quit [Quit: amerlyq]
LiamH has quit [Ping timeout: 272 seconds]
Lord_of_Life has quit [Ping timeout: 258 seconds]
Lord_of_Life_ is now known as Lord_of_Life
wdecay has joined #lisp
LiamH has joined #lisp
orivej has quit [Ping timeout: 248 seconds]
orivej has joined #lisp
Bike has quit [Quit: Bike]
nowhere_man has quit [Remote host closed the connection]
orivej has quit [Ping timeout: 258 seconds]
xkapastel has quit [Quit: Connection closed for inactivity]
orivej has joined #lisp
stepnem has quit [Ping timeout: 245 seconds]
iarebatman1 has quit [Remote host closed the connection]
stepnem has joined #lisp
NickBusey has quit [Quit: Ping timeout (120 seconds)]
NickBusey has joined #lisp
mindCrime has quit [Ping timeout: 246 seconds]
stepnem has quit [Ping timeout: 244 seconds]
eddof13 has quit [Quit: eddof13]
stepnem has joined #lisp
stepnem has quit [Ping timeout: 272 seconds]
Bike has joined #lisp
gxt has joined #lisp
eddof13 has joined #lisp
LiamH has quit [Quit: Leaving.]
stepnem has joined #lisp
colelyman has left #lisp ["Kicked by @appservice-irc:matrix.org : Idle kick: User has been idle for 23+ days."]
gxt has quit [Remote host closed the connection]
gxt has joined #lisp
techquila has joined #lisp
krid has quit [Ping timeout: 258 seconds]
charh has quit [Remote host closed the connection]
akkad is now known as ober
krid has joined #lisp
ebrasca has joined #lisp
Aruseus has joined #lisp
milanj has quit [Quit: This computer has gone to sleep]
schjetne has quit [Ping timeout: 246 seconds]
milanj has joined #lisp
xkapastel has joined #lisp
krid has quit [Ping timeout: 248 seconds]
<manualcrank>
hey guys, according to CLHS for SORT, "The sorting operation can be destructive in all cases."
<manualcrank>
translation: in all cases, maybe. wtf?
<manualcrank>
when is it destructive and when isn't it?
zotan has quit [Ping timeout: 276 seconds]
<manualcrank>
i spent all day trying to figure out why some code wasn't working
zotan has joined #lisp
<manualcrank>
turns out (loop for list across array-of-lists do (sort list #'<)) was dropping list elements
<p_l>
manualcrank: assume it's destructiv
<manualcrank>
but if it were destructive then that loop would work, instead i have to do something like
<manualcrank>
(dotimes (i (length array-of-lists))
<manualcrank>
i don't know, maybe i don't understand what destructive implies
<manualcrank>
seems to imply the argument may be modified in order to return a correct result
<manualcrank>
but not that the argument will be modified into the correct result
random-nick has quit [Read error: Connection reset by peer]
<manualcrank>
for example,
<manualcrank>
(let ((lst (list 3 2 1)))
<manualcrank>
(let ((srt (sort lst #'<)))
<manualcrank>
(eq lst srt)))
<Bike>
manualcrank: "destructive" doesn't mean the argument is changed to be sorted, it means the argument is changed
<manualcrank>
returns T
<Bike>
manualcrank: you still need to use the value returned by sort.
<manualcrank>
but (let ((lst (list 9 3 8 2 1)))
<manualcrank>
(let ((srt (sort lst #'<)))
<manualcrank>
(eq lst srt)))
<manualcrank>
returns NIL
<Bike>
it's not defined.
<Bike>
lst is "destroyed". you can't use it any more.
<manualcrank>
Bike: yes
<Bike>
as for "can be destructive in all cases", that means an implementation can decide when it's destructive.
<manualcrank>
i guess i was used to sort's behavior with arrays of fixnums, which always did the expected thing
<Bike>
two different implementations can differ on when it's destructive.
<Bike>
you can't rely on that either.
<Bike>
use the return value. the argument is destroyed. don't use it any more, even if it looks right on your particular implementation.
<manualcrank>
TIL
rcosta has joined #lisp
rcosta has quit [Client Quit]
Kevslinger has joined #lisp
<manualcrank>
sbcl returns a style warning about discarding the return value of NREVERSE
<Bike>
yeah, same thing.
<manualcrank>
it doesn't do that for SORT though, i really thought SORT worked like in C
lucasb has quit [Quit: Connection closed for inactivity]
paul0 has quit [Ping timeout: 245 seconds]
rcosta has joined #lisp
hhdave has quit [Quit: hhdave]
<Bike>
C doesn't have linked lists or non simple arrays
<pjb>
(map-into array-of-lists (lambda (list) (sort list (function <))) array-of-lists)
<no-defun-allowed>
well, if you give SORT some conses, it'll adjust the CDRs to taste and it's more than possible whatever cons was first before SORTing could be in the middle
rcosta has quit [Client Quit]
<no-defun-allowed>
and conses aren't passed by "reference" in a way like arrays are, if you move conses around, there's no telling which is first
cosimone1 has quit [Ping timeout: 252 seconds]
<manualcrank>
yes, in retrospect sort's behavior makes sense
<aeth>
A cons in C terms is (probably, no guarantees) basically just a container of two pointers (actually, more like the union of pointers and the types small enough to fit in the word size with the type tag included). And a list is just something that starts with that or NIL. And a proper list is a list whose final CDR is NIL.
<aeth>
So with a destructive sort, your list reference could now be pointing to the middle since there is no outer container, just cons-or-NIL.
saravia has quit [Remote host closed the connection]
<manualcrank>
omg i have 226 files with sort used incorrectly lol
<manualcrank>
(all with arrays tho)
Insanity_ has quit [Quit: Connection closed for inactivity]
sellout- has joined #lisp
_jrjsmrtn has joined #lisp
sellout- has quit [Remote host closed the connection]