<makomo>
phoe: what about inheriting just from simple-error?
<dmiles>
thanks because now i can sorta find other examples of not-implemented
orivej has joined #lisp
nanoz has joined #lisp
kajo has quit [Ping timeout: 268 seconds]
orivej has quit [Ping timeout: 248 seconds]
shangul has quit [Remote host closed the connection]
<beach>
dmiles: Conditions are not "thrown" in Common Lisp. They are "signaled". THROW is a Common Lisp function that does something entirely different.
<phoe>
makomo: oh, right
<makomo>
:-)
<makomo>
(same thing for simple-warning as well)
gravicappa has joined #lisp
nowhere_man has quit [Read error: Connection reset by peer]
<dmiles>
yeah the code itself calls signal-condition
vlatkoB_ has joined #lisp
nowhere_man has joined #lisp
nowhere_man has quit [Remote host closed the connection]
Krystof has quit [Ping timeout: 248 seconds]
kajo has joined #lisp
vlatkoB has quit [Ping timeout: 258 seconds]
dkmueller has joined #lisp
scymtym has joined #lisp
wxie has quit [Quit: wxie]
nanoz has quit [Ping timeout: 272 seconds]
lavaflow has quit [Ping timeout: 258 seconds]
dkmueller has quit [Quit: WeeChat 1.6]
notzmv has quit [Read error: Connection reset by peer]
SenasOzys has joined #lisp
random-nick has quit [Ping timeout: 245 seconds]
random-nick has joined #lisp
shangul has joined #lisp
cosimone has joined #lisp
igemnace has joined #lisp
shangul has quit [Quit: sudo rm -rf /usr/*]
cosimone has quit [Client Quit]
nowhere_man has joined #lisp
nopolitica has joined #lisp
Kundry_Wag has joined #lisp
libertyprime has quit [Remote host closed the connection]
Kundry_Wag has quit [Read error: Connection reset by peer]
Kundry_Wag has joined #lisp
Kundry_Wag has quit [Remote host closed the connection]
Arcaelyx has joined #lisp
<jackdaniel>
each time I need to debug asdf a part of me dies ,)
<jackdaniel>
what motivates me even more to finish matroska
<MichaelRaskin>
Putting code into Matroska media container?
<jackdaniel>
no, that's a name of a build utility I'm working on now and then
<MichaelRaskin>
Will it be compatible with all parts of ASDF that people actually know how to use (which are less numerous than the _other_ ones…)
<jackdaniel>
(package name is esdf for sake of confusion and overal chaos)
<jackdaniel>
I have asdf compatibility layer working for simple cases
<jackdaniel>
(i.e it is good enough to fool quicklisp and load systems which doesn't abuse asdf method specializations)
<MichaelRaskin>
Maybe if it doesn't work for complicated cases, we can finally get the dependency graph between definitions to become acyclic
<jackdaniel>
speaking of gross ends of asdf: when I load system with cffi-libffi in dependencies it is not properly cached for the first time
<jackdaniel>
second load makes it load fine. at least on ecl, I would guess that it works fine on sbcl
dkmueller has joined #lisp
nopolitica has quit [Quit: WeeChat 2.2]
lnostdal has quit [Ping timeout: 268 seconds]
lnostdal has joined #lisp
barrybridgens has joined #lisp
nicdev has quit [Ping timeout: 272 seconds]
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nicdev has joined #lisp
<pjb>
(incf jackdaniel)
cosimone has joined #lisp
varjag has joined #lisp
mingus has quit [Ping timeout: 248 seconds]
shangul has joined #lisp
ricekrispie2 has joined #lisp
donotturnoff has joined #lisp
ricekrispie has quit [Ping timeout: 245 seconds]
_leb has joined #lisp
kish has joined #lisp
grewal has quit [Ping timeout: 248 seconds]
grewal has joined #lisp
kajo has quit [Ping timeout: 272 seconds]
mangul has joined #lisp
shangul has quit [Remote host closed the connection]
<skidd0>
i'm trying to understand why I cannot use setf on a symbol i've defined in a let scope
mfiano has quit [Ping timeout: 272 seconds]
<White_Flame>
"does not work" is never a sufficient statemet
mfiano has joined #lisp
<White_Flame>
what error does it invoke, or what behavior does it perform that is incorrect?
<phoe>
skidd0: "works", what do you mean?
<makomo>
i'm assuming the problem is that the value within the hash table itself isn't updated
<phoe>
the latter code defines a lexical variable named VALUE and then sets it to something
<skidd0>
when i attempt a (gethash key hash) after using (setf ..) I get nil
<makomo>
but rather the local variable VALUE
<phoe>
and then it discards that thing and returns the hash-table
<phoe>
SETF sets the place VALUE, and not a place in the hash-table
<phoe>
the (setf value ...) sets the lexical variable VALUE
swflint_away has joined #lisp
<phoe>
if you want to modify the hash-table, use SETF GETHASH
<skidd0>
i thought value was the place in the hash-table
<White_Flame>
imagine that the hash table contains the key/value :foo => 3
<White_Flame>
(let ((value (gethash :foo hash))) ... is the same a (let ((value 3))
mangul is now known as shangul
<White_Flame>
then you set value to 5
<skidd0>
but that's just setting the 'variable' not the hash value
<phoe>
skidd0: if you understand what SYMBOL-MACROLET is, replace LET with SYMBOL-MACROLET and your code will work again
<phoe>
if you don't understand it yet, feel free to read up~
asdf_asdf_asdf has joined #lisp
<phoe>
I mean, in the second case
<White_Flame>
a "place" is a syntactic construct, so a "place" of (gethash key table) when written will update the table. A "place" of VALUE will set the variable VALUE
<oni-on-ion>
strange, what is the error ?
swflint has quit [Ping timeout: 248 seconds]
oni-on-ion has quit [Remote host closed the connection]
swflint_away is now known as swflint
<White_Flame>
skidd0: in the 2nd case, you ar setting the "variable". That's what (setf value foo) does
<phoe>
oni-on-ion: there is no error, just unexpected result
jsatk has quit [Ping timeout: 248 seconds]
<White_Flame>
for any value of foo, given that "value" is a local variable
jsatk has joined #lisp
<skidd0>
i see. I had thought setf set the 'place' the variable value 'came from'. I'm not sure why I thought that
<White_Flame>
that would be very unpredictable
specbot has quit [Disconnected by services]
<phoe>
skidd0: and this is what SYMBOL-MACROLET is for
specbot has joined #lisp
<phoe>
LET creates new places; SYMBOL-MACROLET does not
iovec has joined #lisp
<skidd0>
i see.
nicdev has quit [Read error: Connection reset by peer]
oni-on-ion has joined #lisp
<phoe>
SYMBOL-MACROLET would just replace VALUE with the proper form, in this case, (GETHASH ... ...)
<skidd0>
thank you all. I appologize for a vague "does not work"
<phoe>
so #'(SETF GETHASH) would be invoked instead of setting a lexivar
<White_Flame>
macros in general can let you pass around "places" because they deal with source code constructs, whose shape define the place
vibs29 has quit [Ping timeout: 272 seconds]
<skidd0>
right i see that
<phoe>
oh right, places aren't first class constructs in Lisp, since you cannot pass them to functions or return them from functions or operate on them
<skidd0>
i have much to learn
<phoe>
there is a workaround called a locative - it is an object that can get the value from a place and set the value to a place
<pjb>
phoe: however, you can make first class objects to let you manipulate places: closures!
<White_Flame>
phoe: yeah, that is kind of annoying
<phoe>
and that, in CL, can be implemented as a pair of closures.
<phoe>
pjb: exactly what I am talking about right now (:
<skidd0>
phoe: so that's like a getter and setter?
<phoe>
skidd0: look at the cl-locatives package.
<phoe>
skidd0: yes
<phoe>
except Lisp calls these a reader and a writer
<White_Flame>
a locative is a reader/writer pair
<White_Flame>
something you can call get & set on
<skidd0>
is that similar to :accessor in an object?
<White_Flame>
an accessor sets up a reader function and a setf function
<phoe>
not really
<White_Flame>
that's still not a first-class place/locative that you can pass around
<phoe>
an accessor requires an object that it accesses
<White_Flame>
Common Lisp has no notion of a locative
<phoe>
locatives don't require instance arguments; whatever instances are required are baked into the locative at the moment it is created.
<White_Flame>
hardware locatives were generally a 1-word slot in memory, like a pointer. But a getter/setter lambda pair could do things like access bits packed in an integer or other non-word sized values
dddddd has quit [Quit: Hasta otra..]
dddddd has joined #lisp
Oladon has joined #lisp
karlosz has joined #lisp
v88m has quit [Ping timeout: 258 seconds]
karlosz has quit [Ping timeout: 246 seconds]
jack_rabbit has quit [Ping timeout: 248 seconds]
maxxcan has joined #lisp
MichaelRaskin has quit [Ping timeout: 244 seconds]
v88m has joined #lisp
gravicappa has quit [Ping timeout: 248 seconds]
kish has left #lisp ["Leaving"]
clothespin_ has quit [Ping timeout: 252 seconds]
pankajgodbole has quit [Ping timeout: 246 seconds]
q9929t has joined #lisp
shifty has quit [Ping timeout: 268 seconds]
scymtym has quit [Ping timeout: 252 seconds]
q9929t has quit [Client Quit]
maxxcan has quit [Quit: maxxcan]
cosimone has quit [Quit: WeeChat 2.3]
Josh_2 has joined #lisp
dmiles has quit [Ping timeout: 252 seconds]
dale has joined #lisp
cosimone has joined #lisp
cosimone has quit [Client Quit]
asdf_asdf_asdf has quit [Ping timeout: 256 seconds]
josh5tone has quit [Remote host closed the connection]
dmiles has joined #lisp
barrybridgens has quit [Quit: leaving]
cosimone has joined #lisp
<flip214>
makomo: yes, please. the docstring for ONCE-ONLY got a bit long... too much text?
<flip214>
perhaps the example could be a bit shorter?
<makomo>
flip214: it's mainly because of the examples i think. i could remove one of them, but i think both are good demonstrations
<flip214>
well, I'm afraid that this huge text block won't be read - or that people stop reading after the first 3 lines, or that people only read the last few lines. pick your poison ;/
<makomo>
well, should that really matter? those who want to understand what once-only does will read it :-)
<makomo>
the previous description was really vague
<makomo>
hm, maybe i could remove the first example, since the second one showcases the most general usage?
<makomo>
the first example is the original one that was there
<Josh_2>
If people really want to understand a long doc string is useful imo
<Josh_2>
more info is certainly better than less
cosimone has quit [Quit: WeeChat 2.3]
Oladon has quit [Read error: Connection reset by peer]
<makomo>
yeah, i like (well-written) long docstrings as well :-)
ym555 has joined #lisp
Oladon has joined #lisp
<Josh_2>
Just how long is it? Is there a link so I can see?
<Josh_2>
just long because of the examples. I personally find examples very useful
<tfb>
makomo: I think that so long as the first few lines gives some kind of clue about what the thing does the doc string can be as long as you like within some kind of sanity limit (don't make the machine page...)
<tfb>
makomo: so, in particular I find the new docstring confusing in its first few lines (sorry)
<makomo>
in particular, it doesn't accurately distinguish between evaluating an INITFORM and the corresponding EXPR-i (which happens within the expansion)
<makomo>
but it also makes no mention as to what the macro returns, etc.
<tfb>
makomo: OK, so I'm too tired to make a detailed comment, but I prefer the first two lines of the old version but probably not the remainder of it, on the grounds that the first two lines (really first paragraph) is what I would read to remind myself what it did.
<makomo>
i'll gladly accept any suggestions on how to make the current docstring more clear
SenasOzys has quit [Remote host closed the connection]
SenasOzys has joined #lisp
<tfb>
sorry to not be more helpful
<makomo>
i see what you're getting at, but it's hard to think of a combination of the two that won't be inaccurate
<makomo>
i like the shortness of the previous docstring as well, but it's vague
<tfb>
if you like & can wait (I need to go eat in a few minutes) I will try to meld them but it will be tomorrow (UK time).
<makomo>
and it's hard to distinguish between the two levels of evaluation without explicitly introducing some names for the parts of the result
slac-in-the-box has joined #lisp
<makomo>
tfb: sure, Alexandria is FOSS after all :)
<tfb>
OK, I will try. PS sorry to pop up, criticize your doc string & vanish, that's kind of rude of me: I wasn't thinking.
SenasOzys has quit [Remote host closed the connection]
<makomo>
tfb: don't worry, i don't mind :-)
<tfb>
hmm, can you not authenticate to gitlab.common-lisp.net via github? It thinks you can but then makes bad noises
<makomo>
i'm not sure, but i don't think so?
<makomo>
you'll have to set up 2FA
<makomo>
but it's nothing complicated. KeePassXC for example has a TOTP implementation that you can use
<makomo>
or the mentioned FreeOTP (which is a mobile app i think?)
<tfb>
I have 2FA on github. I'll just make an account on common-lisp.net directly
<tfb>
makomo: OK, I know why: 'email has already been taken': I already *have* an account, if I could remember it :-)
<makomo>
flip214: i've left comments
cosimone has joined #lisp
<flip214>
makomo: saw them, thanks!
donotturnoff has quit [Remote host closed the connection]
manualcrank has joined #lisp
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
lavaflow has joined #lisp
cosimone has quit [Quit: WeeChat 2.3]
v88m has quit [Ping timeout: 268 seconds]
vlatkoB_ has quit [Remote host closed the connection]
v88m has joined #lisp
cosimone has joined #lisp
shangul has quit [Ping timeout: 246 seconds]
t58 has quit [Quit: Overheating...]
nicdev has joined #lisp
donotturnoff has joined #lisp
donotturnoff has quit [Remote host closed the connection]
skidd0 has quit [Quit: WeeChat 2.4]
lavaflow has quit [Ping timeout: 272 seconds]
ggole has quit [Quit: Leaving]
orivej has joined #lisp
_leb has joined #lisp
ym555_ has joined #lisp
ym555 has quit [Ping timeout: 268 seconds]
dkmueller has quit [Ping timeout: 248 seconds]
kajo has quit [Ping timeout: 250 seconds]
t58 has joined #lisp
dkmueller has joined #lisp
dkmueller has quit [Client Quit]
Krystof has joined #lisp
slac-in-the-box has quit [Remote host closed the connection]
kajo has joined #lisp
moei has quit [Quit: Leaving...]
Baggers has joined #lisp
<oni-on-ion>
slime-highlight-edits is fairly cool. but how do i clear them without toggling the mode ?
<Baggers>
this might be a goofy question but what would be the suggested way to implement signed modular arithmatic of sized integers in cl? With unsigned integers I can use (ldb (byte ~size~ 0) ~expression~). Bonus points for approaches the implementation can recongnise and reduce to machine instructions (on two's complement machines)
<phoe>
Baggers: sounds like an implementation-dependent question
Lord_of_Life_ has joined #lisp
<Baggers>
phoe: well the bonus part would probably be. But if the main bit is possible within the standard then that would be more interesting
<Baggers>
(as it is for unsigned integers)
Lord_of_Life has quit [Ping timeout: 268 seconds]
Lord_of_Life_ is now known as Lord_of_Life
pfdietz has joined #lisp
<pfdietz>
Baggers: what exactly do you mean? Out of the box, Lisp's integer operations are the mathematical ones, so if you can express what you want with ordinary math functions CL can do it. Now, *efficiently*...
<Baggers>
I've had a touch to drink so 'exact' might not be in my current wheelhouse. What I'm asking is, given as desire to compute the result of (for example) addin two 8 bit signed integers where where the rest is an unsigned integer that wraps on overflow. How would you recommend doing it in cl. I asked assuming there were different ways of doing it and, not being versed in everything in the spec there might have been coo
<Baggers>
l tricks I hadnt thought of
<Baggers>
'rest is an unsigned integer that' should have been 'result is an 8 bit unsigned integer that'
<Baggers>
fuck agian, i meant signed
ym555_ is now known as ym555
<pjb>
Baggers: what is signed modular arithmetic?
<aeth>
This seems to do it: (defun foo (x y) (declare (type (signed-byte 4) x y)) (- (mod (+ x y (expt 2 3)) (expt 2 4)) (expt 2 3))) (loop :repeat 20 :for i := 0 :then (foo i 1) :do (print i))
<pjb>
Baggers: modular arithmetic is done using MOD.
<aeth>
Baggers: what I did looks like 5 instructions instead of 1 in SBCL but looks pretty fast. Obviously, it needs to stay within the fixnum size to stay fast
<Baggers>
pjb: I expect I'm mucking up the terms. By modular arithmatic I mean the numbers wrap, by signed i was meaning i'm interested in signed integers rather than unsigned ones
<pjb>
(defun modular+ (x y modulo) (mod (+ x y) modulo)) (modular+ -3 -5 64) #| --> 56 |#
<pjb>
Baggers: you seem to have some misconception about what is a number, and what is a modular number. Notably you don't seem to be quite clear on the difference between a modular number, and a representant of that number.
<Baggers>
pjb: I'm aware of mod
elderK has joined #lisp
<pjb>
for example, -3 and 61 are two representant of the same number modulo 64.
<Baggers>
thanks aeth, that's just about what I had too
<aeth>
alternatively you can convert on either side of the calculations, e.g. (defun ub32-to-sb32 (number) (declare (type (unsigned-byte 32) number)) (multiple-value-bind (quotient remainder) (truncate number (expt 2 31)) (- remainder (* quotient (expt 2 31)))))
<aeth>
that will be more expensive for one calculation but if you do e.g. 100 that conversion probably will win
<aeth>
(I mean, 100 before converting back)
<aeth>
or wait, that's what you're doing anyway, so that's faster than my old conversion function
<Baggers>
aeth: thanks, I havent played with truncate before, so that's v.interesting
<aeth>
the function foo seems to be better than my old way.
<Baggers>
pjb: quite likely. I'm happy for you to restate the problem in a precise way if you fancy
<Baggers>
pjb: I took the term 'modular arithmatic' from the sbcl manual and I assumed that combining that with something to clarify I was only interested in signed integers would be enough. Clearly not though
<pjb>
Baggers: well, the question is whether you really want just modular arithmetic (in which case, just use MOD), or if you want to find the representants in some integer interval?
<pjb>
Baggers: Also, notice that in C, modular arithmetic is only specified for unsigned integers. For signed integers, the behavior is implementation dependent.
<Baggers>
pjb: indeed, which is why I didnt ask for C's behaviour as that would only confuse things.
ym555 has quit [Read error: Connection reset by peer]
<pjb>
Baggers: so if the question is to find representants in the range (- (expt 2 (/ p 2))) .. (- (expt 2 (/ p 2)) 1): (defun signed-representant (n modulo) (if (<= (expt 2 (- modulo 1)) n) (- n (expt 2 modulo)) n)) (signed-representant 61 6) #| --> -3 |# assuming the modulo you're interested in are powers of 2.
<pjb>
yes. (defun signed-representant (n p) (if (<= (expt 2 (- p 1)) n) (- n (expt 2 p)) n)) or (defun signed-representant (n modulo) (if (<= (truncate modulo 2) n) (- n modulo) n))
random-nick has quit [Ping timeout: 248 seconds]
<Baggers>
pjb: 'just use mod' is a fairly poor answer when the question was about sized integers. You address this in the code it seems. The reason I asked was that maybe there were more cool tricks people knew than the basic shit I knocked together, seeing different approaches can be helpful
<pjb>
Baggers: again, it's an oxymoron! There's no signed with modular.
<Baggers>
I said 'sized'
<pjb>
There are integers that can be negative or positive, and there is modular arithmetic.
<pjb>
"what would be the suggested way to implement signed modular arithmatic of sized integers in cl"
<pjb>
signed modular arithmetic is a non-sense.
<Baggers>
pjb: ok, maybe I should have asked about mimicking x86s add instruction (where wrapping is defined for signed and unsigned)? But in my mind that distracted from the problem
<pjb>
sized integers doesn't mean much. Notably in the context of modular arithmetic.
<Baggers>
I get it, modular isnt the term
<Baggers>
it's a mistake, I'll happily use whatever the correct term is
<pjb>
Baggers: well, that's yet another question. X86 and most processors use 2-complement representation for negative numbers. This is a trick that means the same circuits can be used to process signed integers or unsigned integers.
<pjb>
So basically, it means we're back to modular arithmetic.
orivej has quit [Ping timeout: 246 seconds]
<aeth>
Baggers: maybe ask in #sbcl if it's possible to get several of the obvious ways to do the calculation optimized in SBCL
<pjb>
The only thing is that the processor computes flags that can be used in different combinations when you want to test signed integers or unsigned integer, notably to test the overflow.
kajo has quit [Ping timeout: 245 seconds]
<Baggers>
and there is exactly why I didnt use that example. We are off on an x86 specific distraction
makomo has quit [Ping timeout: 272 seconds]
<pjb>
If you want to simulate the behavior of X86 add instruction, the best is to read the x86 reference manual. They are very precise about it.
<Baggers>
I am aware of references
kajo has joined #lisp
ym555 has joined #lisp
<pjb>
Baggers: now about integer size, one problem is that in CL, integers are all of infinite size. 2-complement is used to represent them, but on an infinite length. Negative integers are prefixed by an infinite number of 1s, and positive integers by an infinite number of 0s.
<aeth>
pjb: eh, not quite. integers are infinite size, but you can work with subtypes... it's just that you have to stay within the subtype yourself
<pjb>
But there's integer-length that gives you a minimal number of bit used by an integer.
rdh has joined #lisp
<Baggers>
so, let's assume there is some integer thing which wraps at 127 back around to -128. What would me to call that so I can ask a question is a palatable way?
<pjb>
aeth: types in lisp don't impact the representation at all!
<pjb>
Even the values of the type (integer -4 3) have an infinite number of bits.
<aeth>
Baggers: that's called (signed-byte 8)
<Baggers>
aeth: i know, but pjb wants to talk about things a very specific way, so I'm asking what works for them
<pjb>
Baggers: there's no wrapping in lisp.
<aeth>
pjb: well, yes, and they are probably all represented as fixnums or bignums, unless in something like an array with an element-type, or perhaps a struct with a typed slot
<Baggers>
FUUUUUUUUCCCC..
<pjb>
Unless you mean modular arithmetic, using MOD.
pfdietz has quit [Quit: Page closed]
cosimone has quit [Ping timeout: 252 seconds]
<aeth>
(and I know that SBCL does a weird thing where (signed-byte 64) and (unsigned-byte 64) aren't necessarily bignums in certain restricted circumstances)
<Baggers>
thanks for trying aeth
<Baggers>
goodnight
Baggers has left #lisp ["Killed buffer"]
<aeth>
I think the real issue, though is, "Can we get the compilers to optimize the high level into the low level here?" It would reduce the 5 or so instructions into fewer instructions if it's possible.