rumbler31 has quit [Remote host closed the connection]
karlosz has joined #lisp
<ebrasca>
is there lisp for routers?
no-defun-allowed has joined #lisp
sauvin has quit [Read error: Connection reset by peer]
sauvin has joined #lisp
kajo has quit [Ping timeout: 252 seconds]
patlv has joined #lisp
<edgar-rft>
ebrasca: For routers there is a "Locator/Identifier Separation Protocol" usually abbreviated as LISP that has nothing todo with McCarthy's Lisp if that's what you're asking for.
<no-defun-allowed>
so Cisco has two LISP implementations /s
orivej has quit [Ping timeout: 255 seconds]
<ebrasca>
edgar-rft: I am askinkin about some common lisp for routers.
<no-defun-allowed>
ECL is your best bet then.
<no-defun-allowed>
Though, I have tried to get even tinyscheme running on a router, and with a moderate workload it would run out of memory.
<ebrasca>
Some day I like to run CL in my router , my router have LibreCMC running on it.
<no-defun-allowed>
Would you mind checking the output of `free -h`?
<fiddlerwoaroof>
that'll tell you where the version that running is from
smasta has joined #lisp
<p0a>
right -- I think I installed the binary which overrode the package or something
<p0a>
but I installed 1.5.1 just now by using `sh install.sh' and that ``fixed everything''
<fiddlerwoaroof>
Cool
<p0a>
White_Flame: It says quicklisp is already installed
<p0a>
White_Flame: how can I reinstall quicklisp?
<White_Flame>
quicklisp is self-contained in ~/quicklisp
<White_Flame>
but you might have things in your .emacs or .sbclrc still pointing there
<White_Flame>
and yes, I meant viewing the source of the implementation above
<p0a>
ok so source code of CONS etc?
<White_Flame>
yes
<p0a>
why would you want that?
<p0a>
Is it part of optimizing CL further, etc?
<White_Flame>
if the documentation isn't sufficient, or you're just curious as to how things work, or you need to see what performance tradeoffs migth be
<p0a>
so people speak of optimizing CL
Inline has quit [Quit: Leaving]
<p0a>
But I'm not sure what they mean by that exactly. I am writing something which I want to be fast (I already wrote it in C++ but I need interactivity too)
<White_Flame>
optimization is usually avoiding type uncertainty, by giving it enough declarations that it can infer the rest
<p0a>
can you remind me how that is done? decl or declare or what? I can't remember
<White_Flame>
then it doesn't have to include a ton of tests for how to handle different dynamic types
<White_Flame>
but this generally comes into play in combination with a global (declaim (optimize (speed 3) ...))
<White_Flame>
you generally don't hav eto worry about that in the beginning, especially on modern hardware and with the latest sbcl
<p0a>
``modern hardware''
<White_Flame>
it's usually "fast enough"
smasta has quit [Ping timeout: 255 seconds]
<p0a>
my netbook thanks you for the compliment
<p0a>
lol
<White_Flame>
and of course, profiling (see sb-sprof:) usually points out just 1 or 2 hotspots to focus on
<White_Flame>
heh
<p0a>
oh nice. I got to up my game with those tools
<p0a>
I've never used that but I saw something like that recently from a 2018 talk on yotube about clasp
<p0a>
im just a hobby programmer
wusticality has quit [Remote host closed the connection]
wusticality has joined #lisp
wusticality has quit [Ping timeout: 252 seconds]
monokrom has quit [Remote host closed the connection]
rumbler31 has quit [Remote host closed the connection]
keep_learning has joined #lisp
jprajzne has joined #lisp
<p0a>
Quick question, but I remember back in the day in emacs I'd press [ and get a pair ()
<p0a>
I know this is an emacs question but am I right trying to solve this in emacs? Or was it slime that was doing the matching?
<moldybits>
only for certain modes?
<White_Flame>
paredit is probably what you want. it keeps such pairs balanced
andrei-n has joined #lisp
<White_Flame>
it doesn't just auto-insert, but only deletes them in pairs, too, and lets you adjust list to encompass more or less. you'll have to learn some new keystrokes, but it's worth it
<moldybits>
i use (keyboard-translate ?\[ ?\()
<moldybits>
not sure if that's the right way of doing things, though
<p0a>
thank you moldybits
<p0a>
I'll use paredit to
<moldybits>
just be sure to type in all the translations before you evaluate them :p
<p0a>
right lol that actually is funny
<moldybits>
if you try C-[ (key to the right of 'p') now you'll still get C-[ instead of C-(. i never got around to figuring out if you can fix that.
<splittist>
morning
mingus has joined #lisp
<p0a>
alright I am going to restart emacs
p0a has quit [Quit: bye]
corvidzz has quit [Ping timeout: 246 seconds]
corvidzz has joined #lisp
catchme has quit [Quit: Connection closed for inactivity]
p0a has joined #lisp
<p0a>
moldybits: thanks, tnralstate-keyboard works wondrers!
jakevossen has quit [Remote host closed the connection]
<p0a>
Also paredit is cool, I'm going to learn how to use it now a bit
<p0a>
no-defun-allowed: bad typing from cold fingers
<no-defun-allowed>
That works too.
<p0a>
so if I DEFCLASS a class, making instances with make-instance is annoying
<p0a>
is it customary to define a fnction mk-class that does it?
<no-defun-allowed>
Do you figure anyone would want to subclass your class?
<aeth>
p0a: some people define a make-foo that does make-instance 'foo
<aeth>
p0a: make-foo matches a lot of built-ins, e.g. make-array
<no-defun-allowed>
If not, sure. If maybe, then it's probably better to keep the polymorphism and export the class instead.
<aeth>
always export the class and type names imo
<aeth>
Pretty much the only time I have to :: is when someone doesn't do this
<p0a>
I cant' remember what you mean by export but :: is for namespaces right?
<p0a>
aeth: I just want a 2D point, but it just occured to me that #C refers to complex numbers
<p0a>
aeth: I could have had #P or something (my own readtable stuff) but I think I'll just use #C since I don't really need a class for just x,y.
<no-defun-allowed>
Not exactly, exporting relates to how symbols can be accessed between packages.
<no-defun-allowed>
If I were to use a package such as FOO which exported BAR, Ι could write bar to reference that symbol, or foo:bar if I didn't use it.
<p0a>
yeah I never really was able to contribute to anything so I guess that doesn't matter right now
<p0a>
I see, like ql:system-apropos
<no-defun-allowed>
Either way, if FOO didn't export BAR, I would have to write foo::bar. The :: means the symbol is not exported, usually because it is internal to the package.
<no-defun-allowed>
Yes.
<p0a>
okay, so by usign :: you're being naughty
<p0a>
:P because seriously now you're not supposed to access implementation details
<no-defun-allowed>
You're learning quickly.
* p0a
gloats
<no-defun-allowed>
As such, you should export any protocols, classes and variables you would expect a client program to use.
<aeth>
p0a: :: is for internal stuff, and is normally a bad thing, but people never remember to export their class/type names
<aeth>
p0a: using complex for 2D points is actually being really clever because you're having the language do all of the work for you, and you get things like magnitude for free
<no-defun-allowed>
I'm not sure it is suited for idiots, since I didn't understand it for a while when I first learnt about packages.
<aeth>
e.g. I'm pretty sure magnitude is just ABS so e.g. (abs #C(1.5f0 3f0))
<p0a>
right! I think I'll go with #C. Also, thanksf for the packages.pdf
<p0a>
I'll consult soon
<moldybits>
packages were surprisingly difficult to learn. not that i've really learned them, but i can find my way now at least.
<aeth>
p0a: in general (past 2D, where complex might be clever) for points you want a vector because it's the simplest way to represent it
libertyprime has quit [Ping timeout: 240 seconds]
<aeth>
well, possibly a specialized array e.g. (make-array 3 :element-type 'single-float :initial-element 0f0) ; define a function that uses :initial-contents instead of :initial-element and the syntax for creating a point becomes much better
<p0a>
nice. don't worry about it, my application is strictly 2D right now
<aeth>
moldybits: I think packages are weird because they're just namespaces for symbols and have nothing to do with the organization of the code on the filesystem. A very not-Unix/not-Windows way of thinking.
<p0a>
so how can you declare something to be a complex numbeR?
<aeth>
moldybits: It's not that they're wrong it's just that they're different, and different is harder
<aeth>
p0a: here's an example: (the (complex single-float) (complex 1f0 2f0))
<aeth>
note that complex can be more... complex than just complex, since that example is complex single float
<p0a>
Ok I'd like to use double precision
<p0a>
Is it single-doublte?
<aeth>
in fact, in SBCL I get this, so you get ranges there, too: (type-of (cis 43f0)) => (COMPLEX (SINGLE-FLOAT -0.8317748 0.5551133))
<moldybits>
aeth: i think they can be explained better.
<p0a>
cis looks like cos + i*sin but I am not sure what 43f0 is
<aeth>
p0a: it's short-float, single-float, double-float, and long-float. In modern implementations, short-float is usually synonymous with single-float, long-float is often but not always synonymous with double-float.
<aeth>
p0a: I usually pick 42 as my "random" number so I was just mixing it up a bit
<p0a>
gotcha
<aeth>
p0a: since it's in radians I should have multiplied it by pi
<p0a>
aeth: always a problem :P
<aeth>
e.g. (cis (* pi 43d0))
<aeth>
It looks like that should be -1d0 but isn't because of floating point being imperfect
<p0a>
so how does the declare go again?
<p0a>
I tried (declare (x (complex double-float)) (y (complex double-float))) but no go
<p0a>
clhs doesn't have an example I can grok and I'm having a bit of trouble searching online about it
<aeth>
p0a: (declare (type-name variable)) or (declare (type type-name variable))
ltriant has quit [Quit: leaving]
<aeth>
p0a: it's that order because you could declare multiple at once, e.g. (declare (type double-float x y z u v w))
<p0a>
oh there you go nice
<aeth>
It's understandable that you'd get that wrong because it is kind of "backwards" since defmethod puts the class after the variable name like (f foobar)
dddddd has joined #lisp
<p0a>
right it's weird
<aeth>
most people who write declare-heavy code use a macro, usually making it match defmethod syntax
<aeth>
It's actually too long to be standards conforming since it's longer than the minimum maximum length for arrays (including strings)
<aeth>
But that docstring is because while there are dozens of macros like this, mine is by far the most capable.
<p0a>
nice I'm reading teh doc
<aeth>
It does *almost* everything. Whst I'm aware of that it doesn't do is that it doesn't currently support &aux or that niche feature in &key where you don't need to use keywords in your keyword arguments.
<p0a>
i dont get why it errors if you support the wrong type argument in an &optional with a non-valid default value?
<p0a>
at least that's what the doc says
<p0a>
that's a weird `niche' feature lol
<aeth>
p0a: You always need to provide a default value if you provide a type, so I'm saying use NIL if you want the user to have to provide a value (most of the time, at least: there are some things that are actually NIL, like lists and booleans).
<aeth>
s/are actually NIL/can actually be NIL/
<aeth>
Maybe I should rephrase that part a bit
<p0a>
gotcha
<p0a>
don't you mean to say 'if an argument is not provided'? I mean, drop the `valid argument' for `argument' ?
<aeth>
p0a: I think I mean "if a valid default argument is not provided"
<p0a>
right!
<p0a>
i wasn't very precise
<moldybits>
(make-package 'a) (import 'a::hello) hello #| ; The variable HELLO is unbound. |# (hello) #| ; The function A::HELLO is undefined. |#
<moldybits>
why does it show the symbol's home-package only in the (hello) form and not hello
<moldybits>
sbcl's error message
<jackdaniel>
you either use defpackage or wrap make-package and import in eval-when yourself
<jackdaniel>
otherwise it is already to late after whole file is read
<p0a>
is there a way to make 0.0 evaluate to 0.0d0 without me having to write the d0 part?
<p0a>
because 0.0 is a SINGLE-FLOAT but I'd rather if it were a DOUBLE-FLOAT
<no-defun-allowed>
yes, you want 2.0 to make a float
<p0a>
that's no big deal though
<aeth>
yeah, some things are weird and it's even weird to say 2.0f0 and 2.0d0 instead of 2.0f and 2.0d like in many languages
<p0a>
I was even wondering what the `0' denotes
fanta7531 has joined #lisp
<aeth>
p0a: because you're using the exponential notation
<moldybits>
jackdaniel: was that to me?
<aeth>
e.g. 2.5d13
<no-defun-allowed>
the final 0 would be the exponential part
<p0a>
But it must be in uniformity with DEADBEEFx0 maybe
<no-defun-allowed>
think of scientific notation where you have A * 10^B
<p0a>
aeth: wait, why is 2.5d13 equal to 2.5e13
<aeth>
p0a: that's #xdeadbeef
<p0a>
alright, then mevermind
<no-defun-allowed>
in Lisp you write [A]f[B]
<aeth>
p0a: 1.0e1 is the default float, 1.0f1 is single-float, and 1.0d1 is double-float
<p0a>
got it -- e is default
<aeth>
p0a: It's good practice imo to have the "d0" or "f0" because you never know what library (or you earlier in the session and just forgot) was messing with that global imo
<p0a>
sure, in code. in interactive stuff though
<aeth>
right, when I use CL as a calculator I normally set it to double
<aeth>
i.e. (setf *read-default-float-format* 'double-float)
<aeth>
That's why you definitely shouldn't rely on 1.0 being single-float, though
<schweers>
Huh, I didn’t remember that fact about clojure.
<schweers>
<aeth>
Clojure is the furthest of the mainstream languages from the historic Lisps
<aeth>
s/mainstream languages/mainstream languages that may or may not be Lisps depending on your definitions/
<p0a>
clojure also kicks butt
<no-defun-allowed>
Also, the syntax is tainted to the point where literal vectors are used in lambda lists, quasiquotation looks strange, etc, etc
<p0a>
in terms of how much better than java it is :P
<no-defun-allowed>
It can still be awful but less awful than Java. It's not hard to achieve that.
techquila has joined #lisp
<p0a>
well if you can make a better clojure do so
<p0a>
I mean, clojure is probably what has helped a lot of programmers from going insane
<p0a>
in terms of java, again
<no-defun-allowed>
It's a loaded problem. I don't want to mess in a JVM and appease pointy haired bosses.
<p0a>
'xactly
<p0a>
dilbert?
<p0a>
:P
<schweers>
If I had to target the JVM, I would probably give ABCL a try.
<no-defun-allowed>
I want a reflective system with a native compiler and excellent development facilities.
<no-defun-allowed>
Clojure does a terrible job at that, as anything past surface features just become Java internals. Enough of that then, were we talking about floats before?
<aeth>
Common Lisp needs to add support for the root-beer-float type
cranes has quit [Ping timeout: 268 seconds]
<no-defun-allowed>
To be consistent, we also need to add sinks to the number type heirachy.
p0a has quit [Disconnected by services]
p0a has joined #lisp
<p0a>
my emacs crashed lol
<no-defun-allowed>
How'd you do that?
<p0a>
no idea I was writing main.lisp with slime
<p0a>
actually I *was* in the slime repl typing a loop macro and bam
<p0a>
(I didn't hit RET), it just crashed
<schweers>
p0a: are you using a stable version? Are you using experimental features?
fivo has joined #lisp
<p0a>
schweers: 26.1. Not that I'm aware of; I just installed paredit, quicklisp, slime.
<schweers>
I meant build time things. For instance, Cairo support is experimental.
<p0a>
has never crashed bfore so I'm guessing it has omething to do with these tools (also I wasin the slime repl when it happened; I didnt' execute a command)
<p0a>
schweers: not qualiefied enough to answer that, sorry. not sure what you're asking
<schweers>
No problem, it’s off-topic anyway.
<aeth>
paredit used to freeze Emacs briefly when it had some output it didn't like, maybe a few months last year
<aeth>
when using paredit+slime together
<aeth>
(in the slime repl)
<p0a>
ah, it must be that
<aeth>
now, though, it doesn't quite freeze it and C-g can break it
<aeth>
perhaps there was a regression or something
<p0a>
oh yeah you're right. C-g did it. well, crap
<moldybits>
i think i've had emacs crash once
<p0a>
is there an efficient way to `append' in a loop macro?
<p0a>
i.e. imagine (loop for i in '(1 2 3) append (list i (1+ i)))
<schweers>
p0a: so emacs didn’t actually crash?
<no-defun-allowed>
(loop ... appending stuff) or (loop ... nconc stuff)
<no-defun-allowed>
is nconcing a verb? let's see.
<jdz>
p0a: LOOP already is appending as efficiently as it can be done.
<no-defun-allowed>
yep, nconcing works
<p0a>
schweers: yeah, it didn't. my bad. I thought it hanged (I said hang I think?) but C-g did it
<p0a>
jdz: ah, so it's not stupid
<no-defun-allowed>
yeah, appending in a loop should be pretty fast, compared to something like (apply #'append (loop ...))
<p0a>
jdz: because the stupid thing to do would be ... (append list1 list2)...
<no-defun-allowed>
depends on the implementation, but it *shouldn't* be stupid
<p0a>
ok I'll stop worrying about that
<jdz>
As pointed out, if you're generating the lists yourself, you can use NCONC[ING]
<no-defun-allowed>
but, depending on your case, you may find that using lists as a sequence is the issue, where a vector may be better
<no-defun-allowed>
or a list may work fine, but for random access on the list, blablabla, it may be a bigger speedup to avoid lists
<p0a>
okay you're right
<p0a>
I should use a vector actually, thanks for bringing that up
<p0a>
it was a blunder because in my C++ version I Actually use a vector
hhdave has joined #lisp
<schweers>
weirdly enough, some operations are faster on lists than on vectors, where I would have suspected the opposite to be true (on SBCL). Sorting, for instance.
<aeth>
are your vectors of a particular type?
<aeth>
(in the benchmarks)
<p0a>
depends on the sorting algorithm
<p0a>
too
<no-defun-allowed>
I imagine there could be less work if a list is mostly sorted, since it is easier to insert values in the middle of a list.
<no-defun-allowed>
Insertion sort is not the right tool for arrays though.
<beach>
For lists, merge sort can always be used without additional memory, and that's the fastest algorithm in general.
<beach>
For arrays, it is likely that they use quicksort which does not require additional memory, but which is slower than mergesort.
<p0a>
probably orders of log(n) right?
<no-defun-allowed>
I think the fastest sort is n log n?
<p0a>
nothing to drama over
<beach>
I am not talking asymptotic complexity here.
<p0a>
(then again, I was asking about ... loop append)
<p0a>
okay sorry then I didn't get it
<beach>
All good general-purpose sorting algorithms are O(n log n)
<p0a>
okay you were talking abotu the benchmarks. got it
<schweers>
I don’t remember the details on what I was doing, this was just off the top of my head.
<beach>
But mergesort makes at most as many iterations as quicksort and usually many fewer.
<schweers>
beach: isn’t quicksort usually considered to be faster than merge-sort? Or is this from before we knew how to do merge-sort in constanant memory?
<schweers>
<beach>
It would be very surprising if any Common Lisp implementation used insertion sort or any other O(n²) algorithm for SORT or STABLE-SORT.
<p0a>
hmm right now every time I try to type ( in slime it hangs
<p0a>
I have to hit C-g every time. I think it's ParEdit again
<beach>
schweers: On vectors, mergesort either requires O(n) additional memory, or with new O(1) memory algorithms they do more work.
<beach>
schweers: But since sorting a list does not require additional memory, mergesort is typically faster.
techquila has quit [Ping timeout: 240 seconds]
<schweers>
Wait, so it can be done without extra memory on a list, but not on a vector? Did I understand that correctly?
<beach>
Correct.
<beach>
In the list, the CONS cells are enough additional memory to make it work.
<beach>
A vector has no extra space for each element.
<schweers>
Cool, thanks for the clarification) :
<beach>
Sure.
<schweers>
s/) :/ :)/
<p0a>
aeth: my paredit is crashing again, what should I do? every time I try to hit ( it hangs and I have to C-g out of i t
<beach>
This is why I want to write a version of mergesort for vectors that uses stack space if there is some available and that uses the slower O(1) additional memory algorithms if not.
<p0a>
but it's unusable because I can't use the SLIME repl. I could try to get rid of the repl and invoke a new one for now I guess
<aeth>
p0a: are you using paredit in the slime-repl? For some reason, it doesn't like some printed output. Close it and then M-x slime again, but say no to starting a new lisp
<aeth>
Personally, the only thing that reliably gives me this bug is sb-profile:report
<schweers>
p0a: I have a similar problem with spacemacs (which uses smartparens and whatnot).
<aeth>
p0a: By close it I mean close the repl buffer, thus getting rid of the problematic text
<p0a>
I recall something about the DEL operator. I inserted some code in my .emacs as the page on ParEdit recommended
<p0a>
alright I'll do that, thank you
orivej has joined #lisp
<schweers>
beach: I recall you talking about this implementation some time ago. There isn’t a portable way to inspect the stack size and stack usage in Common Lisp, or is there?
<beach>
Right, but it doesn't have to be portable.
<p0a>
so yeah my version was your version but wrong
<p0a>
beach: the reason I wrote it with the /= check is that the list will be long (say half a mil)
<p0a>
beach: and I think I'd rather go through duplicate elements than run `unique' ? Not sure if that's a good idea.
<p0a>
I mean, the algorithm I have in mind works both ways. I'm just not sure which is faster
<beach>
I would uniquify the list first.
<p0a>
alright
<p0a>
looks like delete-duplicate is the fastest of the two
<beach>
"two"?
<p0a>
remove-duplicates and delte-
<beach>
Maybe so, because it does not allocate anything new. But you still need to use the return value.
<beach>
Also, if you have shared list structure, you are in for a surprise with DELETE-DUPLICATES.
<beach>
I would not use it unless you know that you have performance problems.
<p0a>
alright
<p0a>
yeah I went through a lot of trouble yesterday optimizing something with OpenMP
<p0a>
then I realized that the bottleneck is that that sorting+binary search is much faster than what I was doing
<p0a>
so definitley susceptible to optimizing random nonsense instead of focusing on what's important
<beach>
When I program, I try to make sure my data structures and algorithms are good. That way, I almost never need any low-level optimization.
<p0a>
should I bother declaring a list by CONS?
<beach>
It saves a lot of debugging time, since my code is simpler, and I can use a DEBUG quality value of 3 without making the code too slow.
<p0a>
I declared some variables as (complex double-float)
<beach>
I almost never declare any types in my code either.
<p0a>
lol alright
<beach>
Such declarations often turn out to be wrong later on.
<beach>
So not declaring the types saves work.
<schweers>
Especially where integers are concerned, such micro-optimizations can lead to C-like programming. Believe me, you don’t want to get into that if you can avoid it.
<beach>
I second that.
<schweers>
having to worry that adding to a fixnum might not result in a fixnum and the like. It’s often not worth it, even though sbcl tells you that there is a whopping big optimization it can’t perform, because it cannot prove this or that.
<beach>
It won't tell you unless you use (speed 3) or something like that.
<beach>
I always proclaim (speed 0)
<beach>
and (debug 3)
<beach>
It is extremely rare that I need anything faster.
<p0a>
well, what can I tell you. I'd appreciate speed over here right now
<schweers>
yeah, but I often use (speed 3). It is much faster than (speed 0) for my purpose, but I should check out how good or bad (speed 1) or 2 is.
<beach>
p0a: Maybe so. But then you should think about your data structures intead.
<beach>
instead.
<p0a>
definitely words of widsom right there
<beach>
p0a: Good data structures typically pay off an order of magnitude whereas low-level optimizations give much less, and they make your code harder to debug and maintain.
<schweers>
beach: in general I agree with you. I don’t think I have much room for different (or even better) datastructures, at least not without a more-or-less re-write of my whole application. I thing running times of more than a week are a good reason to use performance optimizations ;)
<schweers>
Also, good datastructures and letting the compiler work its magic is not a dichotomy, one can have both. Also, I second your motion that better structures and algorithms give you /way/ more performance benefit.
<beach>
schweers: I wasn't accusing you of anything. :) Sure, there are cases where you do need low-level optimization. I am willing to bet that there are many fewer such situations than people claim.
<schweers>
I agree with you. Don’t worry, I didn’t take it as an accusation.
<beach>
Whew!
<p0a>
:key in REDUCE is weird
<p0a>
for example, (reduce (lambda (x y) (if (< x y) x y)) '(1 2 3) :key (lambda (x) (abs (- x 10)))) will return 7 but I thought 3
<schweers>
while we’re on the topic of performance: I’m very glad that modern free Common Lisp compilers produce code that fast!
<p0a>
oh nvermind I'm stupid
<p0a>
not sure how to do this with reduce or find, I guess I'll use LOOP again :]
<schweers>
Now embedded devices seem to be the last platform where lisp may not be a feasable option. Well, and bootloaders and the like.
<phoe>
schweers: embedded devices get more and more memory anyway
<schweers>
phoe: yeah, luckily
<p0a>
okay I guess my question is: assume `m' is a sorted list of numbers and `x' is a number. Find the number closest to `x'. How would you do it?
<p0a>
In C++ I used `lower_bound' which automatically binary searches
<p0a>
but will I have to write my own binary search instead in CL
<phoe>
binary search on list will be O(n²)
<p0a>
ugh really? ah crap you're right
<phoe>
use an array instead or do a linear loop
<schweers>
Although there seems to be an eternal cycle downwards. We keep finding ways to make tiny computers which use less and less energy and space. Which is good, but also leads to perpetually having to deal with tiny machines.
<schweers>
<p0a>
okay I'll go back to vector, thanks for bringing that up phoe
<p0a>
phoe: nonetheless my question stands (for vector now)
<phoe>
that's actually a good question, do any of the popular util library contain an implementation of binary search
<phoe>
because currently it returns NIL if the element was not found
<phoe>
and if you want to find the closest value then you'll want to return the nearest index nonetheless, so in DO you might want to return LOW instead
<p0a>
it's not that I don't like that Rosetta code stuff
<p0a>
but I'll try to write the binary search in LOOP for the fun of it
<beach>
Interestingly, the description of binary search in the literature is often twice as inefficient as it should be.
<p0a>
hm... ?
<beach>
Again an example of the importance of choosing the right algorithm.
<beach>
Yes, they start by testing for equality.
<p0a>
I dont' know what you mean but I can't imagine how to make it more efficient; the one I have in mind at least goes in the middle and then decides left/right
<beach>
Suppose I wrote a book on bridge building that systematically came up with designs that used twice the amount of material as required. What would engineers think of that book.
<no-defun-allowed>
beach: I think yours is the "alternate procedure" on the English page.
<phoe>
hjudt: I think I know why
<phoe>
IF-LET assumes that all variables are bound both in true-clause and false-clause
<no-defun-allowed>
"This results in a faster comparison loop, as one comparison is eliminated per iteration. However, it requires one more iteration on average." Hmm...
<phoe>
in IF-LET* that assumption is false
<beach>
no-defun-allowed: Oh, good.
<p0a>
ahj, parlez-vous francais?
<beach>
Let me check.
<p0a>
Je m'apelle p0a, j'adore CL, tre bien
<beach>
no-defun-allowed: Indeed. Thanks.
<phoe>
hjudt: (if-let ((x 42) (y nil) (z (frob))) (list :true x y z) (list :false x y z)) is well defined
<phoe>
hjudt: (if-let* ((x 42) (y nil) (z (frob))) (list :true x y z) (list :false x y z)) is NOT well-defined
<no-defun-allowed>
"Multiplicative binary search" also sounds interesting.
<phoe>
because the evaluation stops at Y
<no-defun-allowed>
Actually, no, that is for something else.
<phoe>
in IF-LET* you would have to never have access to lexical variables in the false clause since any of them can be logically unbound
<phoe>
and that is very inconsistent with IF-LET in which you have access to all variables in both clauses
<beach>
p0a: So this binary-search thing is a very good example of what I mean. People choose the wrong algorithm and lose a factor 2 or more. Then they micro-optimize instead, gaining some 10% or so, thereby making the program bigger, harder to debug, and harder to maintain.
<p0a>
beach: quel dommage!
<p0a>
This is 90% of my french so I'm going to stop now
<beach>
Please do.
<p0a>
sorry
<phoe>
hjudt: hope that makes sense
ricekrispie has joined #lisp
ricekrispie2 has quit [Ping timeout: 264 seconds]
Patzy has quit [Ping timeout: 250 seconds]
Patzy has joined #lisp
<p0a>
there's no `else' to `if ... do ...' in loop?
scymtym has joined #lisp
notzmv has joined #lisp
<no-defun-allowed>
I'm pretty sure there is.
<no-defun-allowed>
(loop for n below 10 if (evenp n) collect n else collect (1- n)) works and produces (0 0 2 2 4 4 6 6 8 8)
<p0a>
having some truble with TRUNCATE catually too
<phoe>
middle will only get the primary value nonetheless
<p0a>
idk it complained without VALUES so I added it anyway
<p0a>
yeah that's what I thought...
<phoe>
TRUNCATE returns two values
<p0a>
I agree, the first is kept. I understand that
<phoe>
"it complained without VALUES" because you were not using the second one
<p0a>
I was just a bit worried that maybe that's why SBCL cmplained
<p0a>
I mean, an error.
<phoe>
nth-value 0 would be more idiomatic
<phoe>
it means that you explicitly want the 0th value
<p0a>
style warning: x not used, error: (setq high middl)e found where keyword expected
<phoe>
oh yes, you have errors in there
<no-defun-allowed>
er, you should put DO before your setq
<phoe>
if (< y x) DO (setq ...)
<p0a>
yeah nth-value, thre you go
<phoe>
fix the error first
<phoe>
then the warning should disappear
<p0a>
the `DO' deosn't work
<p0a>
the same error is obtained
<p0a>
Maybe I just just go with the DO loop instead
<p0a>
I don't think there's any clarity in this loop macro
<p0a>
I mean, (do ...)
<p0a>
must a variable be defined bfore I SETQ it?
<beach>
Yes.
<no-defun-allowed>
Yes, either bind it using LET or LOOP or anything that binds lexical variables, or create a special ("top-level") variable using DEFVAR.
[jlk] has joined #lisp
<p0a>
I'm not sure how to bind it in LOOP without giving it a value
<no-defun-allowed>
You can give it a value like NIL.
<p0a>
alright
<no-defun-allowed>
If you're sure it works and you have type declarations, then you should probably pick something of the right type, but it's easier to spot broken cases with something of the wrong type.
<p0a>
can you extend loop?
<p0a>
probably need to roll your own macro I guess
<no-defun-allowed>
Something like the community-created ITERATE might be better then.
<[jlk]>
basically it's a macro that makes a package and some symbols, but then i get a compiler error when i refer to the symbols. the error only comes up with compiling with asdf, repl is fine
<[jlk]>
and even stanger, it all seems to work
pjb has joined #lisp
<[jlk]>
the error is WARNING: undefined variable
<beach>
[jlk]: I hate to repeat myself here, but you really need to indent and format your code correctly if you want help from people here.
<beach>
[jlk]: Common Lisp programmers understand code by looking at indentation, not by counting parentheses, so you need to make sure the indentation reflects that structure.
fanta7531 has quit [Quit: fanta7531]
m00natic has joined #lisp
<beach>
[jlk]: Furthermore, a closing parenthesis should never be preceded by whitespace, and in particular not by a newline.
<beach>
[jlk]: I am telling you this in case you don't get much help. Then you know the reason why.
<beach>
[jlk]: I would have been perfectly happy to help you, but I categorically refuse to read badly formatted code.
<beach>
[jlk]: The indentation might be a question of your having TAB characters in your code.
<beach>
[jlk]: Many pastebin sites can't deal with those.
<[jlk]>
could it be a paste into the web thing?
<[jlk]>
it's just formatted using emacs
<beach>
Then the indentation should be correct.
<beach>
You then need to untabify first.
<beach>
But you still have whitespace preceding closing parentheses.
<[jlk]>
apologies - probably because i've tried writing this about different ways :/
<[jlk]>
what is untabify?
no-defun-allowed has quit [Quit: i will remove one ) from my code each day pjb doesn't post hog]
<beach>
C-x h then M-x untabify.
<beach>
It replaces TABs by spaces.
<beach>
... the appropriate number of spaces.
<beach>
You can also do (setq-default indent-tabs-mode nil) in your .emacs
<p0a>
this would've been so fast in haskell to write
<p0a>
or C++
<p0a>
I can't write CL to save myself lol
* p0a
still tries to do that binary serach
<p0a>
god I hate DO what an awkward loop construct
<jackdaniel>
if these languages work better for you then you should use them, no need to force CL onto yourself. unless you want to learn the language
<[jlk]>
ah - indent-tabs-mode was missing from my init.el
<p0a>
jackdaniel: C++ unfortunately doesn't let me have interactive sessions that work as well
<jackdaniel>
all new concepts are dissatisfying because there is a considerable mental effort to internalize them
<p0a>
jackdaniel: as for haskell I don't know it that well (I don't know how to use I/O) and I think it's slow
<jackdaniel>
our brains are lazy by design
<p0a>
for what it's worth I knew CL once upon a time
<p0a>
:P
<jackdaniel>
I must take your word for that.
<p0a>
lol
<p0a>
jackdaniel: way up I mentioned readtables so I think it's fair to say I wouldn't know that if I wasn't somewhat familiar with LC
libertyprime has joined #lisp
<beach>
[jlk]: Better, yes.
<beach>
[jlk]: What's the error again?
<beach>
[jlk]: And when does it get signaled?
dddddd has quit [Remote host closed the connection]
<[jlk]>
the error is, eg. WARNING: undefined variable COLOUR.SOLARIZED:|base0| when using (defparameter *xxx* COLOUR.SOLARIZED:|base0|)
<[jlk]>
but only when compiling, eg. asdf:compile-system
<[jlk]>
(sbcl if it matters)
<[jlk]>
i assumed wrapping in eval-when would do the trick, but it doesn't seem to
<beach>
So you put it in a file and compile that file?
<beach>
I don't get any error here.
<p0a>
must there be a `test' in DO ? can't I do (do () () ...)?
<p0a>
and just break out of it
<beach>
p0a: LOOP is preferable to DO.
<beach>
p0a: Then you can just write .. when ... return ...
<p0a>
I'll give it a try again but I just can't get it ot work
<beach>
[jlk]: I think you need to give the package definitions, the ASDF system definition, and the way you use this macro.
<p0a>
beach: something annoying is that I have to do for x = step then step, i.e. repeat the `step' part twice even though that's the step... I guess that's okay
<beach>
[jlk]: My (admittedly small) family is telling me that lunch is ready. I hope you get help from someone else.
SaganMan has quit [Read error: Connection reset by peer]
<beach>
p0a: I don't recognize that at all.
<schweers>
p0a: I don’t think that’s right.
<[jlk]>
thanks - enjoy
<p0a>
well anyway I'll write it my own way just give me a sec
<p0a>
I wonder if I can get it working this time
<jackdaniel>
p0a: you may write (do () (nil) (return 42))
<jackdaniel>
test being NIL makes it loop until you break from it yourself
<p0a>
jackdaniel: ! good point :D but I just deleted my DO code and this LOOP code just loaded
<p0a>
cross fingers
<p0a>
hangs lol
<jackdaniel>
when I have some specialized looping need I usually wind up with a custom do-something macro (which is usually based on DO)
<jackdaniel>
that said loop covers a reasonable set of "specialized looping needs"
<p0a>
yeah you're right
<p0a>
but I am *not* getting into remembering macros now to do this thing
<p0a>
that's too much lol
<p0a>
although admittedly there's not much to macros, I'd have to write a mcro around DO and I couldn't hack my way out of a wet paper back if it had "DO" written on it
<jackdaniel>
what do you want to achieve with loop? I'm sure it is somewhere in a backlog, but fast skim doesn't reveal it
Kevslinger has quit [Quit: Connection closed for inactivity]
<jackdaniel>
imo the answer is obvious: none of the variables is available in else branch lexical scope
<pjb>
p0a: you don't do nothing: the learning algorithm in your brain need the time to run an important learning phase, and to perform garbage collection.
amz3 has quit [Quit: WeeChat 2.2]
<jackdaniel>
(and that should be part of if-let* contract)
<p0a>
pjb: I'm seriously confused
<pjb>
p0a: now, I agree that we might be able to design a better learning algorithm that doesn't work with those phases, and garbage collection could be performed in parrallel. Do genetics!
<pjb>
p0a: RETURN refers to BLOCK.
<phoe>
jackdaniel: I'll allow myself to copy that sentence since it sums up the issue really well
<p0a>
I mean, ... the code is small. Can you spot the error?
<jackdaniel>
sure, go ahead
<p0a>
Because I can't...
<phoe>
<3
<p0a>
wait, wtf.
<pjb>
p0a: LOOP wraps the loop in a (BLOCK NIL …) (LOOP :NAMED <FOO> …) in a (BLOCK <FOO> …).
<p0a>
C-c wasn't actually loading my code?
<phoe>
it was compiling it if you are using slime
<p0a>
I tied C-c C-l and the whole file was loaded and now `closest' works.
<phoe>
and loading it
<phoe>
hm, maybe you had something stale in your image
<p0a>
yeah my algorithm is still wrong but that's okay because now it actually terminates
<p0a>
I was wtf'ing really hard because it was stalling
<phoe>
jackdaniel: updated, please take a look at it
<jackdaniel>
well, it doesn't sum up what is written before it, so I'd use different phrasing. what you say is: you can't have if-let* because it would be inconsistent. summing it up you can have if-let* and this is how to do it.
amerlyq has joined #lisp
<p0a>
phoe: yeah that was so frustrating :[
<p0a>
the regulars here teasing me wasn't making it better lol
<lieven>
one could argue that if-let* should expand into nested if-let's
<jackdaniel>
lieven: no precisely because of phoe wrote in there
<jackdaniel>
you have only one else clause
<lieven>
yeah and that else clause should go with the innermost if-let I think
<jackdaniel>
I don't see any added value in such construct
<lieven>
probably wiser not to have an if-let*, only a when-let*
<p0a>
this goes out to all the haters and props to those who believed in me from day 0, https://pastebin.com/K6a8teu8
<p0a>
also pastebin messed up my indentation
<p0a>
do I first sort and then dlete-duplicates or the other way around?
<p0a>
probably first sort
<p0a>
oh dear delete-duplicates doesnt work on vector
kqr has quit [Ping timeout: 250 seconds]
<p0a>
I'm also realizing that it'll be faster to use the equivalent of remove-duplicates for the vector
<p0a>
_death: imho the lower bound step makes it so much easier to do the damn loop
<p0a>
your code looks more generic but I don't need it right now
<p0a>
also kudos for having the nickname `death' on github. that's neat
<_death>
I wrote it when I needed upper-bound to implement a k-least operator
<p0a>
k-least?
<p0a>
ah, so upper-bound = 1-least or something?
<_death>
"Return a vector of the K least elements in the supplied vector. If K is greater than or equal to the length of the supplied vector, returns the supplied vector as-is."
<p0a>
someone was telling me I need to garbage collect my brain or something
<p0a>
like are you serious, C-c doesnt' load my code and I'm supposed to know that lol
<pjb>
Indeed.
<p0a>
well the pastebin is a testimony my brain doesn't need to GC yet :D
<_death>
drink a cup of water to garbage collect some toxins
<schweers>
C-c is a prefix, it doesn’t do anything by itself.
<p0a>
I think it's the blood that provides the GC
<schweers>
no, sleep does
<p0a>
okay idk
<pjb>
there's a GC of chemicals, but also of neuronal connections.
<_death>
schweers: yes, that too
<p0a>
idk it's just a bit annoying because if you had taken a look
<p0a>
schweers: yes I am. pjb deserves it after all that garbage collection trolling they gave me when I was desparete for some newbie help lol
<pjb>
You didn't want newbie help, you said: <p0a> I can't believe I just spent like 8 hours doing nothing
<schweers>
I didn’t see that as trolling, but merely as some light-hearted humor.
<p0a>
pjb: I was hoping to get the thing done and proceed with other stuff in 1-2 hours but somehow time flew by
<pjb>
You can solve this problem by studing genetics, and designing a new brain that doesn't need sleep, but this means designing a new learning algorithms for you neurons!
<pjb>
Now, if you have CL newbie question, you may ask in #clschool.
<p0a>
it's all good
<p0a>
I was just really frustrated with the lisp image thing where C-c wouldn't load my code [but falsely told me it did]
<pjb>
C-c doesn't anything, it's a prefix.
<pjb>
Also, it's for emacs, not for the lisp image.
<p0a>
I meant C-c C-c
<schweers>
That should work, but maybe it had a different package active than you expected?
<pjb>
In slime-mode, it's bound to (slime-compile-defun &optional RAW-PREFIX-ARG) ; I see no loading mentionned in the doc…
<p0a>
schweers: I really don't know why. Since it reported that the thing loaded, I'm assuming a bug or something that I didn't notice
<pjb>
p0a: I use C-c C-k to compile and load the buffer. or C-c C-e to evaluate the last form.
<p0a>
schweers: however C-c C-l loaded the whole file and then it worked. But I only realized that was the issue after spending a lot of time starting at my code lol
<schweers>
I sometimes got bitten by the package thing. I also hardly ever use C-c C-c to load a function
<schweers>
basically I do what pjb just said, or use asdf
<p0a>
pjb: I should porbably use C-c C-k
<pjb>
p0a: type C-h m to see the other commands in the mode.
<p0a>
C-c C-e prompts for slime eval so Im not sure what you'r saying
<pjb>
Sorry, I meant C-x C-e
<pjb>
C-h k and a key gives you the command bound.
<pjb>
C-h w and a command gives you the key it's bound to.
<pjb>
C-h m shows the list of mode specific commands.
<p0a>
Why does compiling give me an error that DECLARE is undefined?
<p9fn>
p0a: fwiw (nothing), i made this little recursive solution to your problem, for whatever reason: https://pastebin.com/1rdjSYSX
<p0a>
C-c C-l is fine; it loads the file but C-c C-k does not compile with the error above
<pjb>
p0a: perhaps a toplevel declare or a body declare?
<p0a>
pjb: Isn't declare the first thing you put after defun + doscring?
<p0a>
(defun f (args) "doc" (declare ...) (body)) ?
amerlyq has quit [Quit: amerlyq]
<pjb>
Yes.
<p0a>
well that's all I have
<p0a>
well now it says no error
<p0a>
whatever
<p0a>
This is crazy lol please ignore me
<p0a>
maybe I'm just really tired
<pjb>
p9fn: bounding indices are [start,end[, not [start,stop].
<p0a>
p9fn: nice. Notice that there's so many if's there
<p0a>
p9fn: I thought I could avoid it somehow. I knew that it'd take lots of conditionals [you did it in less than what I estimated though]
<p0a>
p9fn: also recursion makes it a bit easier
<p0a>
but I wanted an iteartive solution to make sure it's fast. maybe I was just being silly
<p9fn>
yeah i figured it'd be cleaner but there's a bunch of conditionals indeed
<p9fn>
well, for a binary search the recursion depth isn't going to be very deep anyway, right?
<p0a>
it's log(n)
<p0a>
so say in 1000 you go like 10
<p9fn>
yea
<p0a>
oh you're talking about the stack
<p0a>
idk I just avoid recursion if I can, esp. because I can't reason for tail optimization
<p0a>
what does it mean #() is not an array with a fill pointer if I'm using (make-array 0 :adjustable t) ?
orivej has quit [Ping timeout: 255 seconds]
<p0a>
yeah I can't use vector-push-extend on that thing
<p0a>
ok I'm reading on CLHS about it
<pjb>
p0a: what does it mean that an apple is not a legume if I eat a steak?
<p0a>
I too will find you one day on IRC when you're overcaffeinated :P and then it would be my turn to poke fun
<p0a>
anyway I fixed it with (make-array 0 :adjustable t :fill-pointer 0)
patlv has joined #lisp
cosimone has joined #lisp
atgreen_ has joined #lisp
kqr has joined #lisp
<p0a>
anyway, thanks for all the help everyone. I appreciate it a lot
p0a has quit [Quit: bye]
<schweers>
is using MAKE-ARRAY with :ADJUSTABLE, but without FILL-POINTER meaningful anyway?
<ggole>
Sure?
<ggole>
You would use adjust-array rather than vector-push-extend
<ggole>
Not really common, but not meaningless.
<schweers>
hmm, thanks, I didn’t know about adjust array. Makes sense, I guess
igemnace has quit [Quit: WeeChat 2.4]
rumbler31 has joined #lisp
Lord_of_Life has quit [Ping timeout: 255 seconds]
Lord_of_Life has joined #lisp
<phoe>
you can think of it this way: adjust-array is for big big changes, like going from 4k to 8k array
<phoe>
while fill pointer is mostly used for going one by one
<phoe>
since altering the fill pointer is O(1) but it cannot go over the array's current size
<phoe>
while adjusting the array is O(n + m) where n is array size and m is memory allocation cost, but it can change the array's size
<phoe>
you can have an array that is adjustable but without a fill pointer, sure thing
libertyprime has quit [Ping timeout: 250 seconds]
<phoe>
also, fill-pointer is meaningless for higher dimentsional arrays while adjust-array is meaningful for them
varjag has joined #lisp
gxt has quit [Quit: WeeChat 2.4]
patlv has quit [Ping timeout: 255 seconds]
heisig has joined #lisp
<schweers>
phoe: thanks for the further clarification. I never thought of arrays in these terms, partly because I have not yet used multidimentional arrays in lisp.
<phoe>
schweers: according to some myths and folk tales, multidimensional arrays have sometimes been used in the Old Times, but these uses always needed a proper justification and an advanced lisper certificate
<phoe>
luckily, modern times are more lax in that regard
<schweers>
lol
amerlyq has joined #lisp
<p_l>
phoe: Genera source code (and afaik also source code of some other Symbolics' software) nearly never used more than 3 dimensions
<p_l>
with something like 99% of all arrays being 1D?
<phoe>
p_l: exactly
andrei-n has quit [Remote host closed the connection]
<phoe>
that's what I said
xkapastel has joined #lisp
<dlowe>
one wonders if that is a problem trait or a cognitive trait. Do the natural solutions of most problems use 1D arrays, or are we just terrible at solving problems with higher dimensions
<phoe>
obviously we need multidimensional strings
<jackdaniel>
I would bet on cognitive trait. Point still stands of course, even if correct elegant code were written with n dimensions it wouldn't be very readable for its maintainers.
<p_l>
dlowe: large multidimensional arrays tend to use specialized code, not native arrays
<p_l>
also, for efficiency reasons, most multidimensional arrays on "common computing" these days are packed 1D arrays of multi-dimensional entities
gigetoo has quit [Ping timeout: 252 seconds]
<jackdaniel>
I don't personally care how they are implemented (unless I happen to be implementing them), rather how they are used
<dlowe>
That's true of lisp multidimensional arrays too
LiamH has joined #lisp
<jackdaniel>
so whenever there is a specialized hardware to have them, or they are a linked list of linked lists, assuming both variants are acceptable performance-wise -- it is irrelevant
<p_l>
I mean, there are *significant* differences for practical purposes between different ways of implementing multi-dimensional arrays
<p_l>
and CL standard only provides the most generic API on that
<dlowe>
okay, yeah, that's true
gigetoo has joined #lisp
<p_l>
and then there are sparse arrays...
Bike has joined #lisp
moei has joined #lisp
<tfb>
dlowe: there's also the option that it's neither problem nor cognitive but hardware-driven: machines have memory which is a 1-dimensional array
<jackdaniel>
machines does not have a concept of function, that doesn't hold us back
Inline has joined #lisp
<jackdaniel>
there is an abstraction barrier between programmer and the machine
<dlowe>
tfb: it's addressed as a 1-dimensional array
puchacz has joined #lisp
<puchacz>
hi, how do I check if a symbol is bound to a function please?
<dlowe>
fboundp
<puchacz>
tks
<tfb>
dlowe: yes, obviously the implementation is more complex, but the fact that everyone 'knows' how machines work (and machines are then optimized to work the way people 'know') I suspect may bias how they think. However perhaps that comes down in fact to cognitive bias, since machines are not really like that of course
joast has quit [Remote host closed the connection]
<pfdietz>
phoe: yesterday pushed some changes up to my copy of package-local-nicknames-tests. I want to get this put to bed.
<phoe>
pfdietz: Yes, I have seen that - will review it as soon as I go home from work. Which is soon.
joast has joined #lisp
<p_l>
tfb: SIMD packed operations violate that assumption a bit (in some ways)
sjl_ has joined #lisp
wigust- has joined #lisp
wigust has quit [Ping timeout: 252 seconds]
dale_ has joined #lisp
dale_ is now known as dale
heisig has quit [Remote host closed the connection]
rumbler31 has quit [Remote host closed the connection]
jprajzne has quit [Quit: Leaving.]
dddddd has joined #lisp
<phoe>
minion: memo for Xof: you gave me a very hearty laugh with "similar problem with boole, but luckily no-one uses that."
<minion>
Remembered. I'll tell Xof when he/she/it next speaks.
rumbler31 has joined #lisp
mindCrime has joined #lisp
<beach>
OK, what was my simple version of PROPER-LIST-P again?
<pfdietz>
You need to declare (special 3) around that call to list-length, otherwise the implementation is not required to signal an error.
<Bike>
safety 3, but yeah
<pfdietz>
Er, yeah
<beach>
Ah, right.
<beach>
Thanks.
<Bike>
cool that that's enough though
<pfdietz>
You might also do (values (ignore-errors ...)) to discard the second return value of ignore-errors, if you don't want that returned on improper, non-circular lists.
orivej has joined #lisp
rippa has joined #lisp
<flip214>
but that second value is most of the fun here!
<beach>
Or, I can wrap it in (numberp ...)
<beach>
That way I get a true Boolean.
lavaflow has quit [Read error: No route to host]
<jackdaniel>
it will be false if you think about it ;-)
<beach>
A false Boolean! Yay.
lumm has joined #lisp
<flip214>
how about PLUSP?
<flip214>
is a NIL a proper list?
<dlowe>
yes
<flip214>
for beach's purposes, I meant
<flip214>
looks nearly like a boolean false value to me ;)
<flip214>
and not so much like a list
<dlowe>
list-length will return 0 and not error
<beach>
flip214: NIL is definitely a proper list of length 0.
<flip214>
dlowe: but PLUSP would then say it's not a valid list
<beach>
flip214: Not only by my definition.
jayemar has quit [Quit: afk]
lumm has quit [Quit: lumm]
lumm has joined #lisp
<flip214>
beach: I'm aware of the standard. I was asking about the exact use case... NIL is a list is an alist is a plist, so it's not quite that useful for type-checking purposes
lumm_ has joined #lisp
jayemar has joined #lisp
<grewal>
dlowe: The lack of use of multi-dimensional arrays is a combination of both problem and cognitive traits. To use an n-dimensional array, I need objects that can differ in n different ways, and, just as important, ways for which it makes sense to index by number.
<grewal>
dlowe: Humans often have a hard time finding those axes, and many actual problems have too many special cases to make it worthwhile.
<beach>
flip214: In this case, it has to do with checking things like Common Lisp forms or parameter lists.
<beach>
flip214: So either the empty list is acceptable, or the test will be followed by a call to LENGTH.
<flip214>
beach: well, that sounds as if you want an &optional (min-length 0) to check against -- to avoid a possible second LENGTH call.
<beach>
It doesn't matter in this case. It is the first step of compilation. The time will be dominated by optimizations anyway.
milanj has joined #lisp
<beach>
Plus, I don't want PROPER-LIST-P to signal an error. I want to signal my own errors in different situations.
lumm has quit [Ping timeout: 268 seconds]
lumm_ is now known as lumm
<pfdietz>
I want error adaptors. This library or standard thing signals an error; modify it to the error I want.
<beach>
That's another option.
<pfdietz>
This comes up for me in testing. Did the code under test properly signal an error, or was the error a reflection of a bug in that code? Using errors from the CL implementation for the first case makes it confusing.
<beach>
In my code, the goal is to always signal error classes that are proper to that code.
<pfdietz>
Very good :)
<beach>
I am sometimes lazy, in that i don't want to deal with defining errors right then, but I try as much as I can to then go back and fix it later.
Lycurgus has joined #lisp
<beach>
It's a boring task, but clients will thank me later. :)
<pfdietz>
And it enables automated testing. An error that is not one of your code-specific ones indicates an actual bug.
<phoe>
pfdietz: have you run these tests on my modified CCL?
<phoe>
If not, I'll run them now.
<pfdietz>
I have not. I ran them on sbcl.
<phoe>
OK - I'll build the new CCL and run your tests on it.
schweers has quit [Ping timeout: 268 seconds]
<pfdietz>
At this point you mostly want to make sure you're not breaking anything that already works.
<phoe>
This is exactly why I want to run them.
<phoe>
;; 17 tests run, 0 failures.
<pfdietz>
Wait, I had 18 tests.
<phoe>
#+sbcl
<pfdietz>
Ah
<phoe>
One test is related to package locks and therefore #+sbcl'd.
<grewal>
I'm not saying it can't. I'm saying it doesn't
<_death>
clhs says "If position-spec is supplied, but is too large or otherwise inappropriate, an error is signaled." so I would say a NIL value for position-spec should signal an error
<phoe>
^
<_death>
in sbcl file-position has a defknown form that checks the type of the optional argument
<pjb>
phoe: I use 2D arrays of characters to create ascii art.
<cage_>
should i file a bug report to SBCL?
<pjb>
phoe: They could also be used to implement an editor (old editors were designed for fixed length terminal screens or punched cards); nowadays we'd rather use vectors of strings, or more sophisticated data structures.
Aruseus has joined #lisp
<_death>
cage: I guess.. maybe ask #sbcl
cosimone has quit [Quit: WeeChat 2.3]
<cage_>
_death, ok!
sauvin has quit [Read error: Connection reset by peer]
<phoe>
grewal: oh, I see now
<phoe>
yes, that sounds like a possible bug
<jackdaniel>
https://imgur.com/E0hLUpG.png – clim chart put directly in the listener and in a separate window (depends on context)
<cage_>
nice!
<jackdaniel>
thanks :)
<_death>
cool.. needs ticks
<jackdaniel>
ticks, legend, axis labels and much more
<p_l>
what about scigraph? is there any hope for that lib?
<jackdaniel>
I've first looked at scrigraph
<pjb>
moldybits: (make-package 'a) (import 'a::hello) is not conforming.
<jackdaniel>
but I find it hard to use and extend
Aruseus has quit [Remote host closed the connection]
<jackdaniel>
so I've decided to wrap a library of my own (which doesn't have roots in pre-clim environments)
<pjb>
moldybits: because the default value for the :use argument of make-package (and defpackage) is implementation dependent.
<pjb>
moldybits: it could be that the implementation provides a variable named hello by default to new packages.
<jackdaniel>
with a focus on a simple api and code illustrating various clim concepts
<pjb>
moldybits: you should write: (make-package 'a :use '()) (import 'a::hello)
<pfdietz>
Matt Kaufmann is retiring. I wonder what that does to ACL2.
<pjb>
or (make-package 'a :use '(:cl))
<jackdaniel>
p_l: that said scigraph starts with mcclim (it is bundled in apps directory), it is buggy though
jlarocco has joined #lisp
pierpal has joined #lisp
<pjb>
minion: memo for p0a: try to implement DO, then try to implement LOOP…
<minion>
Remembered. I'll tell p0a when he/she/it next speaks.
Zaab1t has joined #lisp
nowhere_man has quit [Ping timeout: 252 seconds]
fanta7531 has quit [Quit: fanta7531]
pierpal has quit [Quit: Poof]
Folkol has quit [Ping timeout: 264 seconds]
pierpal has joined #lisp
iamFIREcracker has quit [Remote host closed the connection]
iamFIREcracker has joined #lisp
<pfdietz>
Looking at the QL systems, I suspect I'm going to discover test coverage is often not very good.
<minion>
Remembered. I'll tell p0a when he/she/it next speaks.
cosimone has joined #lisp
<pfdietz>
Also, what a "wonderful" abundance of different test frameworks! /s
milanj has quit [Quit: This computer has gone to sleep]
atgreen has quit [Ping timeout: 268 seconds]
q3d has joined #lisp
atgreen has joined #lisp
notzmv has quit [Ping timeout: 250 seconds]
notzmv has joined #lisp
lumm has quit [Quit: lumm]
lumm has joined #lisp
lumm_ has joined #lisp
lumm has quit [Ping timeout: 252 seconds]
lumm_ is now known as lumm
hiroaki has joined #lisp
cage_ has quit [Remote host closed the connection]
Zaab1t has quit [Remote host closed the connection]
parjanya has joined #lisp
shka_ has quit [Ping timeout: 246 seconds]
pierpal has quit [Quit: Poof]
pierpal has joined #lisp
mindCrime has quit [Ping timeout: 268 seconds]
lucasb has joined #lisp
vlatkoB has quit [Remote host closed the connection]
scymtym has quit [Ping timeout: 240 seconds]
Kundry_Wag has joined #lisp
Kundry_Wag has quit [Read error: Connection reset by peer]
lumm has quit [Ping timeout: 264 seconds]
atgreen has quit [Ping timeout: 268 seconds]
mindCrime has joined #lisp
kajo has joined #lisp
lavaflow has joined #lisp
aindilis has quit [Remote host closed the connection]
aindilis has joined #lisp
fivo has quit [Quit: WeeChat 1.9.1]
wooden_ has quit [Ping timeout: 244 seconds]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
libertyprime has joined #lisp
Kundry_Wag has joined #lisp
libertyprime has quit [Ping timeout: 252 seconds]
Kundry_Wag has quit [Ping timeout: 246 seconds]
Kundry_Wag has joined #lisp
techquila has joined #lisp
techquila has quit [Remote host closed the connection]
techquila has joined #lisp
Kundry_Wag has quit [Ping timeout: 250 seconds]
libertyprime has joined #lisp
Kundry_Wag has joined #lisp
milanj has joined #lisp
Kundry_Wag has quit [Ping timeout: 252 seconds]
lumm has joined #lisp
Kevslinger has joined #lisp
mindCrime has quit [Ping timeout: 255 seconds]
<moldybits>
pjb: thanks for the info. do you have any idea why the error message is only printing the home package when i try to access it's function slot but not its value slot?
stereosphere has joined #lisp
LiamH has quit [Quit: Leaving.]
<pjb>
moldybits: paste? depends on the implementation.
<pjb>
in ccl, I get:
<pjb>
> Debug: Unbound variable: hello
<pjb>
<pjb>
> Debug: Undefined function hello called with arguments () .
orivej has quit [Read error: Connection reset by peer]
orivej has joined #lisp
akoana has joined #lisp
amerlyq has quit [Quit: amerlyq]
akoana has left #lisp [#lisp]
Bike has quit []
jakevossen has quit [Remote host closed the connection]
q3d has quit [Ping timeout: 256 seconds]
wooden__ has joined #lisp
karlosz has joined #lisp
karlosz has quit [Remote host closed the connection]
libertyprime has quit [Ping timeout: 268 seconds]
karlosz has joined #lisp
karlosz has quit [Remote host closed the connection]
karlosz has joined #lisp
karlosz has quit [Remote host closed the connection]
libertyprime has joined #lisp
sjl has quit [Quit: WeeChat 2.2-dev]
wxie has joined #lisp
ym555 has quit [Ping timeout: 252 seconds]
alca has quit [Ping timeout: 250 seconds]
sjl_ has quit [Ping timeout: 252 seconds]
alca has joined #lisp
moei has quit [Quit: Leaving...]
torbo has joined #lisp
alca has quit [Ping timeout: 246 seconds]
alca has joined #lisp
hiroaki has quit [Ping timeout: 252 seconds]
lumm has quit [Quit: lumm]
<moldybits>
pjb: hm. so i guess it's just an inconsistency in sbcl. what i get is: (symbol-function 'hello) #| The function A::HELLO is undefined. |# (symbol-value 'hell) #| The variable HELLO is unbound. |#
<pjb>
Yes.
<pjb>
you could probably provide a patch pretty easily.
<moldybits>
that's be cool. i'm not buying the `pretty easily' line, though. :)
oni-on-ion has joined #lisp
oni-on-ion has quit [Client Quit]
ym555 has joined #lisp
Bike has joined #lisp
wxie has quit [Ping timeout: 252 seconds]
oni-on-ion has joined #lisp
okeg has joined #lisp
wxie has joined #lisp
ym555 has quit [Quit: leaving...]
karlosz has joined #lisp
<gjvc>
what's the opinion on a sane logging library for cl ?
<pjb>
gjvc: Similar to test frameworks, one size doesn't fit all.
cosimone has quit [Ping timeout: 252 seconds]
<gjvc>
true enough. I am a beginner lisper.
<pjb>
Hence several logging libraries, hence you have to make your own choice, depending on your circumstances, the kind of software, the kind of platform, the kind of requirements for logging, etc
<pjb>
then as a beginner, just use *trace-output*.
<gjvc>
this is backend code generation
<gjvc>
ok
angavrilov has quit [Remote host closed the connection]
<pjb>
with (with-open-file (*trace-output* #P"/var/log/my-software.log" :if-does-not-exist :create :if-exists :append) (main))
wxie has quit [Ping timeout: 250 seconds]
ltriant has joined #lisp
<gjvc>
ace. thank you very much, pjb.
karlosz has quit [Quit: karlosz]
igemnace has quit [Quit: WeeChat 2.4]
lucasb has quit [Quit: Connection closed for inactivity]