pierpal has quit [Remote host closed the connection]
smokeink has quit [Remote host closed the connection]
Kundry_Wag has joined #lisp
Kundry_Wag has quit [Ping timeout: 246 seconds]
rumbler31 has joined #lisp
pierpal has joined #lisp
ebrasca has joined #lisp
scymtym has joined #lisp
anewuser has quit [Quit: anewuser]
varjag has joined #lisp
<shrdlu68>
zigpaw: Morning
zerobaud has joined #lisp
xkapastel has quit [Quit: Connection closed for inactivity]
varjag has quit [Ping timeout: 240 seconds]
<zerobaud>
Does anybody have a good overview / tutorial showing how metaprograming can be done in lisp? For example in C you want a enum of errors that indexes an array of strings (char arrays) corresponding to the error message so that; res = do_something(); if res != ERR_NONE { strerror(res);
Kundry_Wag has joined #lisp
rumbler31 has quit [Remote host closed the connection]
<zerobaud>
But in C only X macros can do it.
<zerobaud>
There are better examples, but anyways... any good documentation about metaprogramming?
<shrdlu68>
I don't understand how the example is metaprogramming.
Kundry_Wag has quit [Ping timeout: 268 seconds]
<zerobaud>
shrdlu68: sorry, I left information out.. I want a single place to add a error message and automatically add a enum. I can keep a enum with error names like ERROR_NONE, ERROR_THIS, then create a char array pointer to a char array with "strings" corresponding to the errors.
<zerobaud>
shrdlu68: now if I want to remove a error I need to edit 2 places...
pierpal has quit [Read error: Connection reset by peer]
<zerobaud>
X macros allow you to add them in one place only trough metaprogramming (using the preprocessor)
pierpal has joined #lisp
<zerobaud>
shrdlu68: or for example, I want to call a error handling function strerror for libc, and also want to handle libelf erros with elf_errmsg, and errors from intel xed dissasembler using xed_error_enum_t2str.
pierpal has quit [Read error: Connection reset by peer]
<zerobaud>
Now, with metaprogramming you can call the correct function without having to return multiple values (orignal return, and a value indicating what lib caused the error)
heisig has joined #lisp
pierpal has joined #lisp
<zerobaud>
so these are practical examples where C really cant do what you want, my question is there a list or tutorial detailing practical examples like those which lisp solves?
pierpal has quit [Ping timeout: 268 seconds]
<shrdlu68>
Sorry, I still don't quite understand the problem, and how whether it has an analogous problem in CL.
<zerobaud>
shrdlu68: I can show a snippet of C not sure if you are familiar with it... I know this is a lisp channel, but if you are I think you will understand. I find it difficult to explain with just words.
<schweers>
zerobaud: what you seems to me more like memory management and maybe dispatch (i.e. OO) than metaprogramming.
<shrdlu68>
zerobaud: As I understand it, you can have a function that checks the value of "errno" and returns the corresponding string. That, or a macro that copy-pastes the code inline. Right?
<zerobaud>
scymtym: right, but X macros are frowned upon, ugly, and really cant do everything you want...
kajo has joined #lisp
<zerobaud>
now I want to learn lisp to see if the afromentioned problems (for which I can provide snippets showing its impossible) can be solved in lisp
akr has left #lisp ["WeeChat 2.2"]
<scymtym>
zerobaud: sure, i just thought that page might help people understand where you are coming from with your question and the example
<schweers>
I for instance was completely unaware of these X macros
<zerobaud>
scymtym: yes thanks, I was about to post it as well since that one line is horrible to read ^_^
<flip214>
zerobaud: I guess you should do (DEFPARAMETER ERROR_NONE "no error") (DEFPARAMETER ERROR_THIS "that") etc. and just use the symbol name as identifier, doing (SYMBOL-VALUE error) to get the string.
<schweers>
Good lord, this is awful
<zerobaud>
schweers: what is?
<flip214>
or do you really need some enumeration via numeric IDs for outside communication? In that case I'd recommend a DEFERROR macro that does DEFPARAMETER and registers the error in an array.
<schweers>
scymtym: thanks for the link to that trainwreck, now I wont’t be able to sleep for two days ;-P
<scymtym>
zerobaud: in lisp, you can run arbitrary lisp code at compile time to generate code to be compiled. there is no separate text-based preprocessor
<zerobaud>
flip214: I guess that fixes this yes..
<schweers>
zerobaud: the X macros
<zerobaud>
schweers: they are indeed :)
<zerobaud>
scymtym: so can I get the names of variables also, and construct code to execute based on them?
<schweers>
zerobaud: in lisp identifiers are first class values, called symbols. Thus, one can have a list of variable names or function names, or whatnot.
jello_pudding has joined #lisp
<scymtym>
zerobaud: not sure what you mean but variables, but yes, macros often generate code based on input that is also code
<zerobaud>
schweers: how would I get the variable name given the variable name? like what is the syntax like?
<zerobaud>
sorry I am really new to lisp, but its metaprogramming that makes me curious to learn it
<schweers>
I highly recommend you read Practical Common Lisp by Peter Seibel (http://gigamonkeys.com/book/), it is a decent into to Common Lisp in general, has a chapter on macros and has practical examples.
<schweers>
<no-defun-allowed>
the variable name is the symbol
<schweers>
Using symbols as variable (or function, or class, or whatever) names can be a bit confusing at first, as you have to bind them to a variable in the macro in order to reference it. It took me quite some time to wrap my head around that.
<zerobaud>
schweers: I am afraid this is something you learn once you actually understand lisp decently
<zerobaud>
well the pdf is going to help with that thanks everyone!
<schweers>
Indeed. This is also the aha-moment that many people claim lisp brings them.
<schweers>
How do you guys use CALL-NEXT-METHOD? It’s not always obvious whether or not there will be another method to call. Do you always call it like this: (when (next-method-p) (call-next-method))?
Kundry_Wag has quit [Ping timeout: 245 seconds]
Selwyn has joined #lisp
<no-defun-allowed>
i call it anyway, since if there is nowhere to go it'll signal an error and that's usually what i want
<no-defun-allowed>
i suppose if you actually want the value though, eeeeh, that's probably the best solution if method combinations don't work
<schweers>
That’s not always what I want.
<no-defun-allowed>
i'd rather have the method combination doing the combining if possible
<schweers>
Sometimes I define a method on a class which derives from the default (STANDARD-OBJECT?), but due to MI there might be more methods to call.
<schweers>
How so?
orivej has quit [Ping timeout: 246 seconds]
<flip214>
schweers: you can use the APPEND method combination to run all methods and get a list of their results; or the + m.c.; etc.
<no-defun-allowed>
i don't know what you intend to do with the value, but if you're combining values with something like + or append, you can define a :method-combination in defgeneric and the method machinery will reduce the values using the combination
<schweers>
Ah, now I understand
<no-defun-allowed>
+, and, or, list, append, nconc, min, max and progn are already defined
<schweers>
Never used a nondefault method combination before, so this didn’t enter my mind
nowhere_man has joined #lisp
undiscovered has joined #lisp
<schweers>
So in such a case one wouldn’t call CALL-NEXT-METHOD in the first place, right?
<schweers>
<no-defun-allowed>
no, the gf handles that
surya123 has joined #lisp
<schweers>
Ahh, progn is predefined ... that may be what I want, I’ll take a closer look at it and what I actually need. Thanks for the input!
zmv is now known as notzmv
cqs has left #lisp ["Good Bye"]
<beach>
I use CALL-NEXT-METHOD when I want to sometimes avoid calling the primary method(s). So I might have (if ... (call-next-method) (do-something-else))
<schweers>
beach: so do I. Sometimes I don’t call it at all (for instance when building a mock/fake/etc)
<beach>
Indeed, if you call CALL-NEXT-METHOD unconditionally, it is likely that there is a method combination for you, or that you might want to do it with a custom method combination.
<beach>
schweers: I see, yes.
robdog has joined #lisp
quazimodo has quit [Ping timeout: 268 seconds]
igemnace has joined #lisp
iovec has joined #lisp
Selwyn has quit [Ping timeout: 245 seconds]
Kundry_Wag has joined #lisp
Kundry_Wag has quit [Ping timeout: 250 seconds]
<hjudt>
is it bad practice to load a foreign library when (quick-)loading the system and fail ungracefully if it doesn't exist? some systems seem to load the lib only on first usage (so it fails later).
Lycurgus has quit [Quit: Exeunt]
pierpal has joined #lisp
pierpal has quit [Client Quit]
pierpal has joined #lisp
jello_pudding has quit [Quit: Leaving, Quit]
Kaisyu has quit [Quit: Connection closed for inactivity]
quazimodo has joined #lisp
<schweers>
hjudt: why fail ungracefully? I have seen systems which offer a restart to choose a different file location.
<hjudt>
ok. even better. but failing on quickload per se is not a no-go right?
<hjudt>
instead of failing later i mean
kajo has quit [Ping timeout: 250 seconds]
Kundry_Wag has joined #lisp
Kundry_Wag has quit [Ping timeout: 268 seconds]
surya123 has quit [Read error: Connection reset by peer]
<hjudt>
another question: sbcl provides a synchronized hash-table. is there something similar for other implementations, or some "trivial-" package?
refpga has quit [Read error: Connection reset by peer]
refpga has joined #lisp
beach has quit [Ping timeout: 252 seconds]
JetJej has joined #lisp
beach has joined #lisp
pierpal has quit [Ping timeout: 240 seconds]
Selwyn has joined #lisp
m00natic has joined #lisp
arquebus has joined #lisp
esrse has quit [Quit: 좋은 주말 되세요]
rozenglass has joined #lisp
arquebus has quit [Quit: Leaving]
Lord_of_Life has quit [Ping timeout: 250 seconds]
smokeink has joined #lisp
Lord_of_Life has joined #lisp
phenoble has quit [Ping timeout: 250 seconds]
phenoble has joined #lisp
robdog has quit [Remote host closed the connection]
<jmercouris>
Yeah, I know a bit about it, can even be changed in sbclrc
<shka_>
if you want to go deeper you can
<jmercouris>
I read about it in PCL and Gentle Introduction to Symbolic Computation
<shka_>
but i would stick to what i provided
<jmercouris>
Yeah, I could make it so that my package is case sensitive by using named-readtables, basically right?
<shka_>
jmercouris: even better, instead of defparameter use define-constant
<shka_>
you can't
<shka_>
and usually it is cumbersome
<jmercouris>
fair enough
<jmercouris>
isn't it defconstant?
<shka_>
just (defconstant administrator '|Administrator|) and use that
<jmercouris>
I don't have define-constant in my system
<shka_>
probabbly
<jmercouris>
ok, just making sure
<jmercouris>
maybe I was missing something
<shka_>
alexandria:define-constant is what i meant
<jmercouris>
Why use the Alexandria version?
<shka_>
but defconstant will work here as well
<shka_>
here defconstant is equally good
w37 has joined #lisp
<jmercouris>
ok
<jmercouris>
thanks for your help!
<shka_>
jmercouris: define-constant is nice because it allows you to pass your own test, but here you don't need it
<jmercouris>
Right
<shka_>
so you can stick to defconstant
<jmercouris>
I saw that in the docs just now
<jmercouris>
thank yoU!
<jmercouris>
or shall I say THANK YOU instead :P
<shka_>
heh, no problem
rumbler31 has joined #lisp
rumbler31 has quit [Remote host closed the connection]
Zaab1t has joined #lisp
<jmercouris>
emacs keeps inserting a '' when I type ' instead of just one '
<jmercouris>
how can I change this?
<jmercouris>
it's getting really annoying, is it part of paredit or something?
<dlowe>
yes
<dlowe>
though it shouldn't in lisp mode
<Selwyn>
certainly you can turn off things like this
orivej has joined #lisp
<Selwyn>
one of the main reasons for using paredit is to take care of things like balancing quotes and parentheses in particular
<schweers>
I wonder how people can live without having paredit like tools.
<dlowe>
note that split and merge work for quotes in paredit
<jmercouris>
it is still doing it
<jmercouris>
maybe it is another one of my modes
<_death>
schweers: I don't use paredit.. fine with it
<Selwyn>
so you can certainly turn it off, but if it is consistently annoying it may be better to 1. use something elsemore suited to the task at hand or 2. get used to the strange behaviour and accept that getting used to it may save time eventually
<jmercouris>
I can't seem to see which it could be
<jmercouris>
but whatever don't worry about it, I have to focus on something else atm
<schweers>
_death: doesn’t that make editing code a total pain?
<_death>
schweers: no.. I really dislike editors that insert things for me
q3d has joined #lisp
<Selwyn>
jmercouris: do you need to output double quotes one by one? or is the behaviour just annoying
<jmercouris>
I want to just output one quote per keypress
<jmercouris>
specifically for single quotes
<jmercouris>
because I often use them instead of (quote ...)
<jmercouris>
double quotes is fine, but single quotes... so annyoing finding myself, it's literally every time ' C-f backspace
<dlowe>
jmercouris: Sure, obviously you want single quotes. This is the first time I've heard of that problem with paredit and lisp-mode
anewuser has joined #lisp
<jmercouris>
I'm not saying it is paredit
<jmercouris>
I asked if it is part of paredit
<schweers>
jmercouris: what does C-h k ' say?
<jmercouris>
I have no idea which mode is doing it...
<jmercouris>
just says self-insert
Essadon has joined #lisp
<jmercouris>
which is expected lol
<shka_>
jmercouris: it won't do it in lisp mode
<schweers>
weird
<schweers>
No advice on it?
Essadon has quit [Max SendQ exceeded]
<schweers>
you did try this in lisp-mode, right?
<jmercouris>
yes
<jmercouris>
no advice on it
<jmercouris>
could be on post-self-insert hook for all I know
<schweers>
you could inspect that then
<jmercouris>
I should try on emacs -q and see if I still get it
<Selwyn>
jmercouris: this is not typical paredit behaviour, I would guess something is broken somewhere or improperly configured. paredit should not output two single quotes after one key press (mine does not)
<jmercouris>
ok, good to know
iovec has quit [Quit: Connection closed for inactivity]
<p_l>
jmercouris: check for modes with names like "electric"
<jmercouris>
I o nly have electric-indent
<jmercouris>
probably is smartparens?
<jmercouris>
yes, it is smartparens
<jmercouris>
there's no smartparens default config for lisp, hnce this behavior
<_death>
since a long time ago, I've been wary of technologies with "x" or "j" in their name.. in recent years "smart" also proved a good needle
<jmercouris>
I'll keep that advice in mind :D, thanks
<jmercouris>
time to restart emacs
<jmercouris>
be back later!
jmercouris has quit [Remote host closed the connection]
flamebeard has joined #lisp
q3d has quit [Ping timeout: 256 seconds]
Bike has joined #lisp
LiamH has joined #lisp
m00natic has quit [Read error: Connection reset by peer]
m00natic has joined #lisp
igemnace has joined #lisp
Essadon has joined #lisp
Inline has joined #lisp
nowhere_man has quit [Ping timeout: 252 seconds]
shifty has quit [Ping timeout: 246 seconds]
rippa has joined #lisp
Josh_2 has joined #lisp
smokeink has quit [Remote host closed the connection]
random-nick has joined #lisp
notzmv has quit [Ping timeout: 250 seconds]
refpga has quit [Ping timeout: 268 seconds]
sjl_ has joined #lisp
igemnace has quit [Ping timeout: 245 seconds]
jaarod2 has joined #lisp
shrdlu68 has quit [Quit: WeeChat 2.3]
dale has joined #lisp
rpg has joined #lisp
kajo has joined #lisp
quazimodo has quit [Ping timeout: 246 seconds]
FreeBirdLjj has joined #lisp
quazimodo has joined #lisp
CrazyEddy has quit [Remote host closed the connection]
amerlyq has quit [Ping timeout: 246 seconds]
themsay has quit [Ping timeout: 246 seconds]
schweers has quit [Ping timeout: 250 seconds]
amerlyq has joined #lisp
cage_ has joined #lisp
refpga has joined #lisp
Kundry_Wag has quit [Remote host closed the connection]
xkapastel has quit [Quit: Connection closed for inactivity]
xkapastel has joined #lisp
jlarocco has joined #lisp
CrazyEddy has joined #lisp
kajo has quit [Ping timeout: 250 seconds]
jprajzne has quit [Quit: Leaving.]
amerlyq has quit [Quit: amerlyq]
Lycurgus has quit [Quit: Exeunt]
FreeBirdLjj has quit [Remote host closed the connection]
varjag has quit [Quit: ERC (IRC client for Emacs 25.2.2)]
FreeBirdLjj has joined #lisp
wigust has joined #lisp
<jonh>
re...reee..start?!
* dlowe
glances nervously at his emacs uptime.
rpg has joined #lisp
metallicus has joined #lisp
<rpg>
Here is a deeply random question: does anyone know if CLIM/SLIME style presentations exist for other programming languages/programming language modes? I have to do a bunch of python these days and I miss the SLIME inspector *really* badly.
<rpg>
... and "python presentation" is about the worst imaginable Google Query.
<verisimilitude>
Does Forth qualify?
jochens has quit [Ping timeout: 245 seconds]
themsay has joined #lisp
<rpg>
verisimilitude: hm... probably just as easy to try to smash SLIME onto python directly as to use forth as a conceptual bridge...
<verisimilitude>
I wasn't aware that's what you were asking.
<verisimilitude>
I thought you were simply asking about languages with similar facilities, not a language to bridge with.
<rpg>
verisimilitude: Yes, what I would like to do is have a python mode that, like SLIME, has mouse-able data structures.
phlm has joined #lisp
<verisimilitude>
I'm familiar with the name iPython to refer to some fancy Python environment; have you tried that?
<verisimilitude>
Also, there's a Python implementation in Common Lisp, so you could simply use that.
<zigpaw>
maybe PyCharm have something remotely similar during debuggin? (just guessing)
<rpg>
verisimilitude: I'm using python (like many people) because I need access to numpy, pandas, and some machine learning libraries; I'm not sure that would be possible in a CL port of python.
<rpg>
zigpaw: Yes, I could try that.
Arcaelyx has quit [Ping timeout: 246 seconds]
<verisimilitude>
I don't believe it would, no, rpg.
<verisimilitude>
It's amusing to me how people write in Python, but not for Python itself, as Python is a poor language.
<rpg>
That's ok, I think the presentation idea is feasible, but ...
<rpg>
verisimilitude: I think Python is underrated; they have gone out of their way to pull a lot of the nice features of Lisp, CLOS, etc.
<verisimilitude>
The creator has gone out of his way to gimp many features as well, lambdas, TCO, etc.
<rpg>
I still miss "homoiconicity", and things like CHANGE-CLASS for a long-lived environment.
<rpg>
verisimilitude: TCO?
<verisimilitude>
That is Tail-Call Optimization.
<rpg>
verisimilitude: Ah! I came up with only Total Cost of Ownership, which isn't quite right!
surya123 has quit [Ping timeout: 245 seconds]
<verisimilitude>
Python instead has a default stack limit of 1,000 and doesn't perform TCO purely because Guido doesn't care for it.
<rpg>
verisimilitude: One thing I am appreciating is optional type checking (mypy, pyre), which I really wish I had in CL.
<verisimilitude>
I don't understand what you mean.
egp_ is now known as brother_complexi
brother_complexi is now known as brother_complex
<dlowe>
rpg: I'm working on a whole-image type checker for sbcl, but it's slow going
brother_complex is now known as complex_brother
Arcaelyx has joined #lisp
<rpg>
dlowe: I like the checking that SBCL does, but I confess to a long term lack of understanding and queasiness about SBCL's use of CL type declarations for checking instead of (in addition to) optimization
complex_brother is now known as complex__brother
<rpg>
Of course, not having macros makes it easier for Python.
complex__brother has quit [Quit: Leaving]
<rpg>
I have an old copy of Drew McDermott's Nisp lying around, which does type checking, but it's written in such an idiosyncratic style that I've never managed to successfully comprehend it.
themsay has quit [Ping timeout: 244 seconds]
themsay has joined #lisp
Kundry_Wag has joined #lisp
asarch has joined #lisp
rpg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
anewuser has quit [Quit: anewuser]
themsay has quit [Read error: Connection reset by peer]
themsay has joined #lisp
<sukaeto>
IIRC, if you put type declarations in your code, SBCL tells you when you make a type error
Arcaelyx has quit [Ping timeout: 250 seconds]
<sukaeto>
aaaand, he's gone
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #lisp
<sukaeto>
minion: memo to rpg: you could try out elpy. I've used it a bit with iPython in inferior Python mode. It's not as nice as SLIME, and I eventually stopped using it, but it might give you what you want.
<minion>
Remembered. I'll tell rpg when he/she/it next speaks.
anamorphic has joined #lisp
FreeBirdLjj has quit [Ping timeout: 245 seconds]
random-nick has quit [Read error: Connection reset by peer]
<anamorphic>
Hi, I have some foreign code that deals with a pointer to two kinds of things: FOO and BAR, but in my CFFI code, I'd like to prevent a FOO pointer being passed to a function where BAR pointer is expected, so I came up with this scheme: https://pastebin.com/YU7fx2XK but it feels like I'm probably re-implementing something. Is there a better way to go?
Mr-Potter has quit [Ping timeout: 245 seconds]
m00natic has quit [Remote host closed the connection]
Arcaelyx has joined #lisp
moei has joined #lisp
rozenglass has quit [Remote host closed the connection]
rpg has joined #lisp
Denommus has joined #lisp
sauvin has quit [Remote host closed the connection]
gxt has quit [Ping timeout: 268 seconds]
Mr-Potter has joined #lisp
Kundry_Wag has quit [Remote host closed the connection]
random-nick has joined #lisp
atgreen has joined #lisp
random-nick has quit [Read error: Connection reset by peer]
metallicus has quit [Quit: WeeChat 2.3]
mathrick has quit [Ping timeout: 250 seconds]
pierpal has joined #lisp
<phoe>
anamorphic: I don't think so. CFFI pointers are not typed, so having a simple structure wrapper around them is the way to actually keep them typed in the Lisp world.
<phoe>
Or the way you did it - I wasn't aware of CFFI foreign types working that way.
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #lisp
notzmv has joined #lisp
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #lisp
asarch has quit [Quit: Leaving]
<Bike>
cffi does maintain types for pointers, it just ignores them, right? would it be difficult/possible/a good idea to have it type check those?
* |3b|
didn't think it maintained any types
<Bike>
i mean you can specify (:pointer :int) and stuff
<|3b|>
at least on sbcl it just returns an (untyped) sbcl pointer value, with no extra cffi type info as far as i know
<|3b|>
yeah, you can specify pointer types, but mostly ignored
<anamorphic>
Like that (:pointer :int) syntax?
pierpal has quit [Ping timeout: 246 seconds]
orivej has quit [Ping timeout: 240 seconds]
ggole has quit [Quit: ggole]
<phoe>
This information is ignored I think
<Bike>
yes what i'm asking is
<Bike>
could cffi be modified to not do that
<phoe>
I mean, the returned pointers are not typed in any way and a pointer returned from a function that is supposed to return an int pointer can be dereferenced as a float pointer later on and no type errors will happen.
shifty has joined #lisp
<phoe>
I suppose it could, sure - it won't be backwards compatible, obviously, but the type information could be stored somewhere and then checked.
<LiamH>
I think the reason for the pointer types is for conversion on dereferencing, especially for structs.
xantoz has quit [Read error: Connection reset by peer]
<phoe>
LiamH: you can't dereference a pointer in CFFI without providing the type that you want to dereference as.
xkapastel has quit [Quit: Connection closed for inactivity]
<phoe>
CFFI:MEM-REF requires a foreign type as its second argument.
<sjl_>
> Pointers do not carry around type information. Instead, type information is supplied when pointers are dereferenced.
<sjl_>
> A type safe pointer interface can be developed on top of an untyped one. It is difficult to do the opposite.
rpg has joined #lisp
<shka_>
anamorphic: i like your code
<LiamH>
cffi-libffi, which allows for struct by value call/return, required the type of the struct be specified in order to do the conversion. As a convenience, the ability to specify the type of pointer was added to facilitate similar conversion for call-by-reference, though I don't think that is implemented.
pierpal has joined #lisp
<karlosz>
is there a quick way in cl to interpret an unsigned 32 as a signed 32?
pjb has joined #lisp
<karlosz>
so like f(2^32 - 1) = -1
<sjl_>
no, you have to write the conversion function