freenode/#lisp - IRC Chatlog
Search
0:02:39
no-defun-allowed
In my case, I am pretty sure my inference techniques are NP-hard - but I guess the "type" of my objects would be the union of their protocols, with all the real names stripped out for gensyms.
0:03:01
lotuseater
in things about legal expressions: i tell people that i can easily use eg '1/z for the name of a lexically scoped parameter and everybody gets confused and responds that's not understandable
0:03:24
no-defun-allowed
That's decidable (I think ML type inference is also NP) but if you also permit arbitrary code in the FSM I describe, it is definitely undecidable.
0:03:42
no-defun-allowed
lotuseater: Heh, yeah, I once showed some Scheme code to someone and they got confused about the ? in number?
0:40:36
no-defun-allowed
I'll have to check, but it's part of the symbol reading stuff and thus not a macro character.
1:08:40
thmprover
Question: when I write something like (defstruct (foo (:type list)) name age weight), this is just creating a list "under the hood", right? In the sense that (make-foo "Joe" 38 145) produces the same result as '("Joe" 38 145).
1:09:33
no-defun-allowed
From memory (I don't usually use a different :type), yes, except that you can mutate the result of the former but not the latter without UB.
1:10:50
thmprover
So would omitting the '(:type list) part, would that change the memory layout at all?
1:12:01
lotuseater
good question, I thought about structs up to now in general represented in memory as vectors
1:12:03
no-defun-allowed
That would create its own object, which is trivial to detect as an instance of the structure-class FOO.
1:12:42
no-defun-allowed
That wouldn't be too far off, except that structures are tagged as such. (type-of (make-foo ...)) should return FOO every time.
1:12:54
no-defun-allowed
oni-on-ion: It is undefined behaviour as to what happens if you modify literal data.
1:15:22
thmprover
So wait, let me get this straight, without the 'type, it's layout is like a vector? More analogous to C structs in memory? Whereas `(:type list)` would make it a linked list in memory (well, I just confirmed on my repl it's `equal` to a list with the same components)
1:18:10
White_Flame
or DISASSEMBLE the creation, and see the multiple cons allocations for each list cell, vs a single allocation for the stuct
1:18:53
lotuseater
thmprover: using CLOS for easy stuff could be a bit heavy, DEFSTRUCT is very lightweight and you can also have simple inheritance
1:19:29
White_Flame
I use (:type list) to automatically create accessors for the fields of preexisting lists
1:21:04
thmprover
I've been working on a pattern matching program to do symbolic math, and I'm about to add integrals to it, which is what prompts my asking.
1:21:30
thmprover
I wasn't sure if there was any advantage to a defstruct + (:type list), or just a vanilla '(list 'integral ...)
1:22:14
White_Flame
you don't know if (INTEGRAL ...) is an actual intentional integral, or a list that happens to have that value there
1:23:08
no-defun-allowed
I would use standard-classes first, then structure-classes if the added indirection of standard-class is a problem.
1:23:39
thmprover
Although highly unlikely, I would want to avoid the accidental '(integral ...) mistaken as an intentional integral
1:24:07
lotuseater
thmprover: maybe chapters 8 and 15 of the PAIP book help you :) it gave me good insights
1:26:05
thmprover
lotuseater: those are good chapters of PAIP, I'm actually mulling over chapter 15.
1:27:29
thmprover
I've been reading the first few chapters of BPS while studying the SCMUTILS library. SCMUTILS is what prompted this little adventure, trying to get something similar working in Common Lisp.
1:32:21
thmprover
Macros are like superpowers: they're awesome, until you accidentally destroy Metropolis.
1:32:31
oni-on-ion
seems most lisp code i've found dont even use macro for C #define style text replacement; i dont undersantd
1:33:28
oni-on-ion
perhaps "lisper" is more occupied with sound of mechanical keyboard to type stuff out over and over
1:33:35
lotuseater
somebody once want to told me C and Lisp macros are the same stuff o_O and C++ templates are the greatest stuff out there
1:33:52
no-defun-allowed
I would have to disagree, but I don't really want to if you like C++ templates.
1:34:16
no-defun-allowed
drmeister once famously said C++ templates are to Lisp macros as IRS tax forms are to poetry.
1:40:59
matzy_
i have a question, i'm surprised by the results of running my function here: https://pastebin.com/P6idQqdW
1:42:03
lotuseater
but if I also would be really good in C++ there where less job problems ... it does not fit in my head
1:42:24
no-defun-allowed
UNLESS will evaluate its body if the test value is false. Consider what (unless (member 4 '(0 1 2)) body ...) will do.
1:43:50
matzy_
i understand what that does, it recurses, so I go "three" layers deep so to speak until I enter 2, so I understand why 2 prints, but does it then go "back up the stack" so to speak and complete the code for the rest of the functions, past the point where the recursion was called?
1:43:53
no-defun-allowed
Also, note that FORMAT will always be called after. I'll guess either of those is what surprised you.
1:45:09
matzy_
so it hits the first recursive function, goes in there, that hits a recursive function which is valid and completes, then that exits back to the middle function, which completes, and then that exits to the outer function which then completes?
1:45:22
no-defun-allowed
My guess is this function is supposed to keep prompting the user until they enter 0, 1 or 2, and then do something with the result.
1:45:54
no-defun-allowed
So you are asking it to always write the number with FORMAT outside a conditional form.
1:46:20
matzy_
yeah, i guess i thought when you hit a recursive function, you go in there and stop executing the rest
1:47:04
no-defun-allowed
It does continue as normal. I don't think Common Lisp has a notion of recursive or non-recursive functions.
1:47:27
no-defun-allowed
(But it is not a tail call anyway, you still have stuff to do after calling PLAYER-TURN2.)
1:48:13
no-defun-allowed
A Common Lisp implementation doesn't really care, it does the same thing if it is calling the same function or another one.
1:50:22
White_Flame
most recursive programming is usually "if still-recursing, then do some work & recurse, else print/return final value"
1:51:12
no-defun-allowed
My guess (again) is that you may have thought that form would be tail-recursive, which is the case if there's nothing more to do, and so immediately jumping into that function, without setting up returning to the current function, maintains the illusion that you have called them like normal.
1:52:00
no-defun-allowed
If you write the base case first, then a reader who is familiar with induction would be able to decide if your code will behave and not infinitely recurse.
1:54:37
White_Flame
if you just want to jump back, GOTO style, (tagbody try-again (format t "Please ...") ... (unless (member ..) (go try-again)) ...)
1:59:11
surabax
cl-glfw3's fragment-shader-example instantly closes on launch without any errors on SBCL and Windows 10
2:07:04
surabax
It seems to be dying on the gl:uniformf call that updates the time variable in the render function
2:24:32
surabax
Looks like the examples don't clean up the OpenGL state after themselves so they break if you try to run more than one without reloading everything
3:02:12
matzy_
no-defun-allowed: yeah you're guess sounds right, i basically thought as soon as the UNLESS condition was met and it called itself (the recursive function), it stopped executing and just exectured taht function instead rinse and repeat
3:03:16
no-defun-allowed
Right, UNLESS and WHEN will not affect the evaluation of anything outside of their bodies by themselves.
3:04:19
matzy_
so my thought was the only function call who should hit that second format statement would be a call that did not hit the unless and did not stop to execute another function
3:04:55
matzy_
but it makes sense - if i was calling some other random function, i sure as well wouldn't want my original/main function to stop executing after the call and return
3:06:16
matzy_
it's just weird to think about what value x has at various stages in that process, to me at least
3:07:08
matzy_
if i enter 4, 3, and 2 (lets always use this as an example - it rejects 4 and 3 and is only happy when i enter 2)
3:57:29
no-defun-allowed
It does not, short of the recursively defined structure that looks like <L> ::= () | (<L> . <L>)
8:57:51
loke[m]
Recently my SLIME is only giving me 20 frames in the debugger. Is there a setting somewhere that limits this? It's consistently 20 frames, so it seems as it's just stopping.