mwnaylor has quit [Remote host closed the connection]
mwnaylor has joined #commonlisp
decweb has quit [Quit: Konversation terminated!]
decweb has joined #commonlisp
NotThatRPG has joined #commonlisp
jonatack has joined #commonlisp
mosin has joined #commonlisp
jonatack has quit [Ping timeout: 246 seconds]
<fengshaun>
is there a limit to what can be done at compile-time with macros? I tried to embed an asset into the final binary and it seems like I could read a file and dump the contents all at compile time with the macro and assign the resulting string to a parameter and use it.
<fengshaun>
I haven't looked into how djula does its memory-store though
<fengshaun>
I guess the question is: does the compiler have access to (or uses) a full cl environment that can run any cl code?
<bike>
fengshaun: the compiler can evaluate arbitrary code, sure. sometimes the environment in the sense of what variables are available etc is different, but you have access to all standard functions and variables and such.
<fengshaun>
nice, so as long as information is available at compile time, then it can be used. awesome, thanks!
<fengshaun>
any pointers on when eval-when is appropriate vs a macro? I can't think of when eval-when would be useful
<bike>
frequently, eval-when is useful when you want to make functions etc available to macro expanders
<fengshaun>
oh alright, for both compile and runtime, thanks!
<aeth>
if you're doing a really fancy macro, it's usually easier to just do everything in compile time functions, which return lists
<aeth>
`(foo ,bar) is conceptually simple, but it gets tricky with size... but each function called from that macro can still consist of basically just things like `(foo ,bar)
<mosin>
aeth bike can you guys give code examples?
phantomics_ has quit [Read error: Connection reset by peer]
spdegabrielle has quit [Quit: Connection closed for inactivity]
<ixelp>
Eclector/code/reader/tokens.lisp at master · s-expressionists/Eclector
<aeth>
on the more trivial toy example side of things, nothing's stopping you from doing something like this (inside of an eval-when) for use in macros: ,(defun add (&rest rest) `(+ ,@rest)) ,(add 'x 'y 'z)
<ixelp>
(defun add (&rest rest) `(+ ,@rest)) => ADD, and then (add 'x 'y 'z) => (+ X Y Z)
<aeth>
of course, for toy examples, you don't really see the point vs just using quasiquote directly
<aeth>
but pretty much any extension of that sort of concept may have a use in macros
screwlisp has quit [Ping timeout: 248 seconds]
istewart has joined #commonlisp
NotThatRPG has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jonatack has joined #commonlisp
jonatack has quit [Ping timeout: 268 seconds]
jonatack has joined #commonlisp
random-nick has quit [Ping timeout: 252 seconds]
jonatack has quit [Ping timeout: 272 seconds]
jonatack has joined #commonlisp
markb1 has quit [Ping timeout: 246 seconds]
ixelp has quit [Ping timeout: 244 seconds]
ixelp has joined #commonlisp
semz has quit [Quit: ZNC 1.8.2+deb2ubuntu0.1 - https://znc.in]
jonatack has quit [Ping timeout: 252 seconds]
mosin has quit [Ping timeout: 246 seconds]
semz has joined #commonlisp
markb1 has joined #commonlisp
ixelp has quit [Ping timeout: 246 seconds]
ixelp has joined #commonlisp
jonatack has joined #commonlisp
markb1 has quit [Ping timeout: 248 seconds]
emaczen has joined #commonlisp
markb1 has joined #commonlisp
dim` has joined #commonlisp
dim has quit [Ping timeout: 268 seconds]
dim` is now known as dim
decweb has quit [Quit: Konversation terminated!]
decweb has joined #commonlisp
markb1 has quit [Ping timeout: 260 seconds]
markb1 has joined #commonlisp
JuanDaugherty has joined #commonlisp
Pixel_Outlaw has quit [Remote host closed the connection]
markb1 has quit [Ping timeout: 272 seconds]
markb1 has joined #commonlisp
istewart has quit [Quit: Konversation terminated!]
chomwitt has joined #commonlisp
stanrifkin has joined #commonlisp
Ruby has quit [Ping timeout: 248 seconds]
Ruby has joined #commonlisp
markb1 has quit [Ping timeout: 268 seconds]
robin_ has joined #commonlisp
robin has quit [Read error: Connection reset by peer]
bpanthi977 has quit [Ping timeout: 260 seconds]
bpanthi977 has joined #commonlisp
thuna` has joined #commonlisp
bpanthi977 has quit [Ping timeout: 246 seconds]
markb1 has joined #commonlisp
jon_atack has joined #commonlisp
jonatack has quit [Ping timeout: 252 seconds]
decweb has quit [Quit: Konversation terminated!]
King_julian has joined #commonlisp
JuanDaugherty is now known as ColinRobinson
markb1 has quit [Ping timeout: 246 seconds]
<fengshaun>
that's cool, haven't hit a scenario where I'd feel the need yet, but I'm only 1 week into cl :S
<fengshaun>
looks very powerful though
<aeth>
yes because you could e.g. write a similar function that selects the function to call based on the number of arguments in the rest variable instead of hard coding +
<aeth>
things like that could be clearer in a function than inside of the macro itself
emaczen has quit [Ping timeout: 245 seconds]
markb1 has joined #commonlisp
thuna` has quit [Ping timeout: 246 seconds]
<beach>
fengshaun: If you are a Common Lisp newbie, you might want to join #clschool where people hang out specifically to answer newbie questions.
ghodawalaaman has quit [Quit: Ping timeout (120 seconds)]
ghodawalaaman has joined #commonlisp
<fengshaun>
thanks, I've joined #clschool. I don't ask questions often though, usually clhs is enough
<beach>
I see.
<fengshaun>
I should setup an offline indexed copy of clhs for fast access at some point
<fengshaun>
even better, integrate it into emacs
pve has joined #commonlisp
shka has joined #commonlisp
thuna` has joined #commonlisp
edgar-rft has joined #commonlisp
mishoo has joined #commonlisp
shawnw has joined #commonlisp
edgar-rft` has quit [Ping timeout: 260 seconds]
King_julian has quit [Ping timeout: 244 seconds]
markb1 has quit [Ping timeout: 248 seconds]
King_julian has joined #commonlisp
veqq1 has joined #commonlisp
ColinRobinson is now known as JuanDaugherty
<JuanDaugherty>
there are things to know that arent in the hyperspec
<JuanDaugherty>
but you'll learn them in the proper time
<beach>
The Common Lisp HyperSpec is an HTML version of the standard, but the standard certainly omits lots of things to know, because it is not meant to be a pedagogical document.
veqq has quit [Ping timeout: 248 seconds]
veqq1 is now known as veqq
<beach>
So things that have to do with conventions and preferences are often not stated.
<beach>
As a person implementing a Common Lisp system, you are just supposed to know.
<JuanDaugherty>
which is the spec target audience
<beach>
Mainly people implementing Common Lisp systems.
<jackdaniel>
beach: DEFCSTRUCT is a CFFI operator, note the fourth letter
<beach>
Oh, sorry.
<jackdaniel>
mivanchev: no, you need to provide your own initialization code
<mivanchev>
jackdaniel, yes but in _what_ for
<mivanchev>
form
<jackdaniel>
to allocate it (but not initialize) you may use with-foreign-object
<mivanchev>
I see some examples of a plist being used as an initializer
<jackdaniel>
and initialization by using with-foreign-slots I think
<mivanchev>
"By default, convert-from-foreign (and also mem-ref) will make a plist with slot names as keys, and convert-to-foreign will translate such a plist to a foreign structure"
<jackdaniel>
oh, then there you have, a constructor :)
<jackdaniel>
fwiw I find it very informative to check out the implementation of various cffi operators to see how they work and how to use them
<jackdaniel>
M-. is your friend in that case
<mivanchev>
I'm a vim person but we also have introspection :)
<jackdaniel>
oh, you are one of them ;-)
<jackdaniel>
jokes aside, introspection is your friend
markb1 has quit [Ping timeout: 244 seconds]
tjbw has joined #commonlisp
[1]X-Scale has joined #commonlisp
X-Scale has quit [Ping timeout: 272 seconds]
[1]X-Scale is now known as X-Scale
markb1 has joined #commonlisp
mivanchev has quit [Remote host closed the connection]