masinter has quit [Remote host closed the connection]
X-Scale has quit [Quit: Client closed]
ebrasca has quit [Remote host closed the connection]
lagash has quit [Ping timeout: 260 seconds]
Lord_of_Life has quit [Ping timeout: 255 seconds]
Lord_of_Life has joined #commonlisp
alexsotodev has left #commonlisp [#commonlisp]
kuao has joined #commonlisp
X-Scale has joined #commonlisp
X-Scale has quit [Quit: Client closed]
X-Scale has joined #commonlisp
bilegeek has joined #commonlisp
waleee has quit [Ping timeout: 264 seconds]
X-Scale has quit [Quit: Client closed]
X-Scale has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
dinomug has joined #commonlisp
lagash has joined #commonlisp
Pirx has quit [Ping timeout: 248 seconds]
bubblegum has joined #commonlisp
anticrisis has quit [Read error: Connection reset by peer]
khrbtxyz has joined #commonlisp
anticrisis has joined #commonlisp
dcb has quit [Quit: MSN Messenger 4.1.0]
X-Scale has quit [Ping timeout: 248 seconds]
dinomug has quit [Remote host closed the connection]
dinomug has joined #commonlisp
bubblegum has quit [Ping timeout: 248 seconds]
Oladon has joined #commonlisp
pve has joined #commonlisp
semarie has quit [Quit: WeeChat 4.0.4]
<smlckz>
how do you represent (as in usable in type, deftype, coerce etc.) sum and product types in the type system of common lisp, if possible at all?
<jcowan>
It's not very clear what (lambda (x) (if x 1 (/ 1 0))) is actually allowed to do. / says the consquences are unspecified, which means they are unpredictable but harmless, but what does "harmless" actually mean? Does reducin this to (lambda (x) 1) count as harmless?
azimut has quit [Ping timeout: 256 seconds]
<moon-child>
smlckz: a product type could be (cons a b) or similar (or a structure type whose slots are appropriately typed
<moon-child>
there are no sum types, but (or a b) is a union type
<smlckz>
so no type safety for hand crafted tagged union as sum types?
<moon-child>
well, how are you going to represent your sum types?
<moon-child>
say, integer + integer. You could represent it as integer * 2, that could be a (cons integer boolean) or whatever
igemnace has joined #commonlisp
tibfulv_ is now known as tibfulv
<smlckz>
cons does work, why does (list types...) doesn't seem to work?
notzmv has quit [Ping timeout: 264 seconds]
rtypo has joined #commonlisp
<smlckz>
it seems like `or' for single ''atomic'' values, but doesn't care about lists..
msavoritias has joined #commonlisp
habamax has joined #commonlisp
semarie has joined #commonlisp
Cymew has joined #commonlisp
rgherdt has joined #commonlisp
Oladon has quit [Quit: Leaving.]
<beach>
Well, Common Lisp doesn't really have a LIST type. It is just a sequence of CONS cells, and there can be arbitrary sharing of sublists. So it is impossible to verify that every element of a list always has the same type.
<ixelp>
One Reason Typeclasses Are Useful | The Coalton Language
tibfulv has quit [Remote host closed the connection]
<mzan>
I'm not an expert, but my 2cents are that: if you come from Haskell-like languages, you usually starts from algebraic-data-types definitions; in CL apparently this is not the usual way; but if you want, you can do this in CL; if the code become too much verbose, you can introduce macros; there are other libraries/macro allowing to define ADT in a rather compressed way.
dinomug has quit [Remote host closed the connection]
simendsjo has quit [Remote host closed the connection]
<agm>
smlckz: in C, product types are structs. maybe you can use CL's structures for that purpose
simendsjo has joined #commonlisp
pranavats has left #commonlisp [Error from remote client]
Nisseboda has quit [Quit: Leaving]
Nisseboda has joined #commonlisp
zxcvz has joined #commonlisp
zxcvz has quit [Client Quit]
bendersteed has quit [Quit: bendersteed]
yitzi has quit [Remote host closed the connection]
blaaa has joined #commonlisp
Cymew has quit [Ping timeout: 255 seconds]
puke has quit [Remote host closed the connection]
puke has joined #commonlisp
Nisseboda has quit [Killed (NickServ (GHOST command used by blaaa))]
Nisseboda has joined #commonlisp
puke has quit [Excess Flood]
puke has joined #commonlisp
Nisseboda is now known as Guest5827
blaaa is now known as Nisseboda
agm has quit [Ping timeout: 240 seconds]
alexsotodev has joined #commonlisp
alexsotodev has quit [Ping timeout: 258 seconds]
<lispmacs[work]>
hi, I'm reading through the hyperspec, but I'm just a little confused still about what the FUNCTION function does and why it is needed
<beach>
FUNCTION is not a function but a special operator.
<lispmacs[work]>
err, yes
<beach>
It allows you to access something in the function namespace.
<beach>
Common Lisp has separate namespaces for variables and functions, so you can't just use the name of a function as a variable.
<lispmacs[work]>
okay
<beach>
If you have, say, (defun foo (...) ..) and (defparameter foo), you can access the variable by just typing foo, but the function requires (function foo).
<lispmacs[work]>
in the spec, it talked about using FUNCTION to "coerce a lambda expression into a closure in which the lexical environment in effect when the special form is evaluated is captured along with the lambda expression"
<lispmacs[work]>
that was the part I was wondering about.
<beach>
Oh, I see.
<lispmacs[work]>
it seems like you still capture the lexical environment even if you don't use FUNCTION
<lispmacs[work]>
at lest in SBCL
<beach>
That's because LAMBDA is a macro so that (lambda (...) ...) expands to (function (lambda (...) ...))
<beach>
You may consider the direct use of (function (lambda (...) ...)) as obsolete and just use the macro instead.
<lispmacs[work]>
ah, so maybe not all implementations necessarily implement that as a macro?
<lispmacs[work]>
okay, I guess then that brings me back to the question of why the spec indicated it was needed in the example
<beach>
What example?
<lispmacs[work]>
undered "Closures and Lexical Binding"
<lispmacs[work]>
(defun two-funs (x)
<lispmacs[work]>
(list (function (lambda () x))
<lispmacs[work]>
(function (lambda (y) (setq x y)))))
<beach>
Can you give the section number?
<lispmacs[work]>
the section numbers don't appear to be included in this GCL info version
<beach>
The likely explanation is that the macro was introduced late in the standardization process, and they didn't update the examples.
<beach>
By the way, examples are not normative, and many of them are not even valid anymore.
<lispmacs[work]>
Top >> Evaluation and Compilation >> Evaluation >> Closures and Lexical Binding
<lispmacs[work]>
okay, well I think that reduces the fog down to a light mist, anyway
<beach>
Well, it doesn't say that it is needed.
<beach>
So it is still valid.
<beach>
It is still true that the FUNCTION operator is required to coerce the lambda expression into a closure.
<beach>
But the LAMBDA macro hides that by expanding to a FUNCTION special form.
<bike>
it's 3.1.4
<beach>
Yeah, I found it.
<beach>
lispmacs[work]: There is a lot of historical baggage in the standard, and it is often not worth asking "why", because the answer is just that "for historical reasons".
<lispmacs[work]>
so, I wonder what would happen in that example if FUNCTION was not present (explicitly or from a macro)
<bike>
(lambda () x) would be macroexpanded into (function (lambda () x)), etc, so it would work out the same
<beach>
Then, it would be an error, because LAMBDA would not be an operator.
<bike>
unless that includes "from a macro" i guess
<lispmacs[work]>
so, let's say (lambda (y) (setq x y)) was not coerced into being a closure
<beach>
lispmacs[work]: A compound form is something like (<symbol> <arg> ...), and if <symbol> is not defined as an operator, it is an error.
<beach>
So if you remove the macro LAMBDA, then LAMBDA is no longer an operator, and you have an error.
<lispmacs[work]>
would that error be throw when the defun was evaluated, or when you tried to call the lambda function later?
<beach>
A warning would typically be "signaled" (not thrown) at compile time, saying that LAMBDA is not a known operator.
<lispmacs[work]>
I'm talked about the undefined X variable
<beach>
You can try it by trying to compile the same thing, replacing LAMBDA with LSDJLSFJ for intance.
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<bike>
lispmacs[work]: there's no operator to let you define a local function that isn't a closure, which i think you might be trying to get at? like if LAMBDA didn't exist, (lambda (y) (setq x y)) would just be interpreted as a call to an unknown function LAMBDA, which would cause other problems
<beach>
(defun two-funs (x) (lskdjlsdkj () x)) says lskdjlsdkj is an unknown function.
<lispmacs[work]>
bike: yeah, so if that is the case, why would it even occur to them to have an example where they used (function (lambda (y) (setq x y)))
<beach>
So if LAMBDA were not defined as a macro, you would get the same warning.
<bike>
lispmacs[work]: because they're explaining what closures are
<lispmacs[work]>
for the purpose of coercing a lambda expression into a closure
<beach>
lispmacs[work]: I no longer understand your problem with the example. What would you have done instead?
<bike>
the point of this section is to explain closures, rather than to say "here's this special coercion process"
<lispmacs[work]>
just left out FUNCTION, I guess
<bike>
why?
<beach>
lispmacs[work]: But then they would not have explained the special operator.
<lispmacs[work]>
it apparently is redundant
<bike>
i mean, it's not exactly redundant. without writing out FUNCTION they'd have to explain that lambda is a macro that expands into a use of function.
<lispmacs[work]>
so, what does lambda expand out to again?
<beach>
(lambda (...) ...) expands to (function (lambda (...) ...))
<beach>
lispmacs[work]: Try it yourself.
<lispmacs[work]>
how?
<beach>
(macroexpand-1 '(lambda (x) x))
<beach>
It will come back with #'(lambda (x) x) which is a reader macro for (function (lambda (x) x))
<lispmacs[work]>
so, what does the already expanded LAMBDA do? it must NOT capture the lexical environment
<lispmacs[work]>
right?
<beach>
I am not sure what you are talking about. FUNCTION is not a function. It does not treat its argument as a form.
<bike>
again, there is no way to not capture the lexical environment.
<lispmacs[work]>
so, (lambda (x) x)) expands to (function (***LAMBDA*** (x) x))
<lispmacs[work]>
with the asterisks added in
<bike>
no.
<beach>
Yes.
<bike>
yes?
<lispmacs[work]>
so, either this is infinitely recursive, or ***LAMBDA*** must not be the same as lambda
<bike>
FUNCTION is a special operator. it doesn't macroexpand its operand.
<lispmacs[work]>
and ***LAMBDA*** must not capture lexical environments
<bike>
No.
<beach>
I just told you that FUNCTION is not a function, so it does not treat its argument as a form.
<lispmacs[work]>
so what does ***LAMBDA*** do
<beach>
It does nothing.
<beach>
It is an expression interpreted by the operator FUNCTION.
<bike>
It's like how when you write (let ((foo 4)) ...), this is not interpreted as a call to (foo 4), it's interpreted as a variable binding. LET does its own thing.
alphacentauri has quit [Quit: WeeChat 4.1.0]
<beach>
Yes, bike's example is good. LET is another special operator that interprets its first argument as something other than a form.
djuber has joined #commonlisp
<lispmacs[work]>
so, if I'm getting this right: really what is actually going on all over the place in our code is FUNCTION special operator is being called and passed a lambda form, but that is rather verbose and inconvenient to type, so we have a lambda macro that expands to this
<bike>
more or less, although referring to special operators being "called" isn't really accurate
<lispmacs[work]>
executed immediately?
<bike>
like again you don't "call" LET
danse-nr3 has quit [Remote host closed the connection]
danse-nr3 has joined #commonlisp
<beach>
lispmacs[work]: The FUNCTION operator is passed a lambda "expression", not a lambda "form".
<lispmacs[work]>
okay
<beach>
lispmacs[work]: A "form" is an "expression" meant to be evaluated.
<beach>
lispmacs[work]: And it crucial that the argument of FUNCTION is not a "form" because then it would be macroexpanded, and you would have an infinite recursion.
<beach>
And, yes, special operators are handled directly by the compiler which typically turns them into machine code.
<lispmacs[work]>
okay, I think I'm getting it. I can do (defvar foo) (setq foo '(lambda (x) (+ 1 x)))
<lispmacs[work]>
then
<lispmacs[work]>
(funcall (function #.foo) 3)
<lispmacs[work]>
gives 4
<beach>
Sounds right.
<beach>
But you can't do (funcall (function foo) 3).
<lispmacs[work]>
I tried that first but got an error
<beach>
Of course.
<beach>
Again, the argument to FUNCTION is not a form, so it is not evaluated.
<lispmacs[work]>
since function foo is not defined
<lispmacs[work]>
FUNCTION takes an expression, right?
<lispmacs[work]>
a lambda expression
<beach>
It takes a lambda expression or the name of a function.
<beach>
Which is the first explanation I gave you, but that was not what you asked for.
danse-nr3_ has joined #commonlisp
danse-nr3 has quit [Read error: Connection reset by peer]
<lispmacs[work]>
I can't be the first person to ever get a bit confused by all that
<beach>
You aren't.
<beach>
But we are happy to explain it to you.
<lispmacs[work]>
thanks
<beach>
Pleasure.
liminality has quit [Ping timeout: 260 seconds]
<beach>
As a Common Lisp application programmer, you never have to worry about (function (lambda (...) ..)). You use FUNCTION only with a name as an argument, and you use the macro LAMBDA to create closures.
<beach>
As an implementer of Common Lisp systems, on the other hand...
<beach>
lispmacs[work]: Oh, and the standard document can be confusing, because it is mainly meant for the latter category. We don't really have a language reference manual.
* beach
now regrets having said that, being sure that there will be objections.
<jcowan>
Well, people *use* it as a language reference manual faute de mieux, although it is pretty mieux to start with.
igemnace has quit [Remote host closed the connection]
liminality has quit [Ping timeout: 245 seconds]
bienjensu has quit [Ping timeout: 264 seconds]
liminality has joined #commonlisp
yitzi has joined #commonlisp
danse-nr3_ has joined #commonlisp
_cymew_ has joined #commonlisp
X-Scale has quit [Quit: Client closed]
azimut has quit [Ping timeout: 256 seconds]
X-Scale has joined #commonlisp
dino_tutter has quit [Ping timeout: 260 seconds]
attila_lendvai has joined #commonlisp
dcb has joined #commonlisp
dcb has quit [Client Quit]
tyson2 has quit [Remote host closed the connection]
ldb has quit [Ping timeout: 245 seconds]
djuber has quit [Remote host closed the connection]
dcb has joined #commonlisp
ldb has joined #commonlisp
attila_lendvai has quit [Ping timeout: 264 seconds]
danse-nr3_ has quit [Ping timeout: 240 seconds]
msavoritias has quit [Remote host closed the connection]
pranavats has joined #commonlisp
mooseball has quit [Quit: Leaving]
tok has quit [Remote host closed the connection]
danza has joined #commonlisp
cage has quit [Quit: rcirc on GNU Emacs 29.1]
Guest5827 has quit [Read error: Connection reset by peer]
Nisseboda has quit [Read error: Connection reset by peer]
dino_tutter has joined #commonlisp
ldb has quit [Ping timeout: 246 seconds]
ldb has joined #commonlisp
ldb has quit [Remote host closed the connection]
random-nick has joined #commonlisp
tyson2 has joined #commonlisp
danza has quit [Ping timeout: 252 seconds]
danza has joined #commonlisp
alphacentauri has joined #commonlisp
rogersm has joined #commonlisp
anticrisis has joined #commonlisp
bubblegum has joined #commonlisp
notzmv has quit [Ping timeout: 240 seconds]
tyson2 has quit [Remote host closed the connection]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
tyson2 has joined #commonlisp
Nisseboda has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Nisseboda has quit [Ping timeout: 252 seconds]
_cymew_ has quit [Ping timeout: 240 seconds]
NotThatRPG has joined #commonlisp
X-Scale has quit [Quit: Client closed]
Pixel_Outlaw has joined #commonlisp
dinomug has joined #commonlisp
X-Scale has joined #commonlisp
tyson2 has joined #commonlisp
bubblegum has quit [Ping timeout: 248 seconds]
masinter has joined #commonlisp
ronald_ has quit [Read error: Connection reset by peer]
ronald_ has joined #commonlisp
danza_ has joined #commonlisp
danza has quit [Ping timeout: 255 seconds]
larix1 has joined #commonlisp
Gleefre has quit [Remote host closed the connection]
X-Scale has quit [Quit: Client closed]
danza_ has quit [Ping timeout: 240 seconds]
NotThatRPG has quit [Ping timeout: 248 seconds]
X-Scale has joined #commonlisp
lagash has quit [Remote host closed the connection]
lagash has joined #commonlisp
yitzi has quit [Read error: Connection reset by peer]
mgl has quit [Ping timeout: 255 seconds]
tyson2 has quit [Remote host closed the connection]
tyson2 has joined #commonlisp
X-Scale66 has joined #commonlisp
Gleefre has joined #commonlisp
X-Scale has quit [Ping timeout: 248 seconds]
tyson2 has quit [Remote host closed the connection]
attila_lendvai has joined #commonlisp
simendsjo has quit [Ping timeout: 255 seconds]
Oladon has joined #commonlisp
waleee has joined #commonlisp
attila_lendvai has quit [Ping timeout: 258 seconds]
X-Scale66 is now known as X-Scale
tok has joined #commonlisp
mgl has joined #commonlisp
liminality has quit [Ping timeout: 240 seconds]
liminality has joined #commonlisp
shka has quit [Ping timeout: 240 seconds]
Algernon91 has joined #commonlisp
NotThatRPG has joined #commonlisp
jeffrey has quit [Ping timeout: 248 seconds]
pve has quit [Quit: leaving]
<Pixel_Outlaw>
Hello! I'm not terribly web savvy but I was kind of wondering if anyone had ideas to capture video from a Raspberry Pi and serve it up on a webpage in CL?
<Pixel_Outlaw>
Maybe even pictures would work since it's a security camera thing...
<Pixel_Outlaw>
I'm not sure if it's normal to send pictures over and over again to a webpage in some update loop.
<Pixel_Outlaw>
I do know though that we have like 4+ web server options. :)
Algernon91 has quit [Ping timeout: 264 seconds]
<waleee>
dump the x last still images from the cam in a path that the server can find and serve them statically seems like the easiest option
<waleee>
some ffmpeg finnicking might be necessary for the image extraction from the video
Oladon has quit [Quit: Leaving.]
mgl has quit [Ping timeout: 245 seconds]
<Pixel_Outlaw>
Well, realtime video is probably OK. There is a catch I didn't mention. I'm doing sphereical photography which gets transformed into a panorama from a sphere image.