libera/#commonlisp - IRC Chatlog
Search
12:35:25
pjb
nij-: have a look at https://github.com/informatimago/lisp/blob/master/common-lisp/cesarum/file.lisp#L248 & following.
12:35:45
pjb
nij-: what's wrong with http://groups.google.com/group/comp.lang.lisp/msg/1bab4b5bae1fdca3 http://groups.google.com/group/comp.lang.lisp/msg/190d771c0e033a1c ?
12:37:06
pjb
nij-: also, access seems to be like & and defref: http://informatimago.com/articles/usenet.html#C-like-pointers-in-Lisp
13:15:27
VincentVega
How does SBCL decide when to call a compiler macro? I am trying some examples from CLHS define-compiler-macro and the original function is called.
13:17:23
phoe
all examples up to (funcall (compiler-macro-function 'square) '(funcall #'square x) nil) work as expected
13:20:10
beach
VincentVega: As I recall, the OPTIMIZE values may determine whether the compiler macro is called.
13:22:53
phoe
VincentVega: and check the SBCL manual for optimization qualities, maybe some high DEBUG or something can cause SBCL to not use compiler macros
13:24:48
phoe
#sbcl might provide more information, or the devs could write something in the manual about how CMs are treated
13:26:37
VincentVega
phoe: thanks! I will probably ask there. http://ix.io/3M4h optimization options didn't turn out to have an effect.
13:31:39
VincentVega
oh, nevermind, top-level compiling it was the reason. Putting it in a function definition works out just fine.
16:00:39
rotateq
Okay definitely one of the most funny lines I read in the last days. :) "Sometimes, when the full moon rises and foolish programmers declare (optimize (safety 0)), you can hear the howl of the Loopus, and screams of source code that is ripped to shreds."
17:27:01
ksp
Hello, does anyone know how to split a string by a specific character? I want each line of my data to be a seperate string
17:29:01
jackdaniel
you may find a manager to easily download libraries and quicklisp.org ; as for introduction
17:29:04
minion
ksp: please see pcl: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
17:40:16
rotateq
jackdaniel: and I no more confuse the other PCL abbreviation (Potable Common Loops)
17:41:35
rotateq
since some longer time now ^^ first I thought "hmm, what shall this sb-pcl module name stand for?"
17:54:27
jackdaniel
btw there is an interesting history behind "mixins" and "flavors" (so I've read somewhere) - there was an icecream shop on the campus where they were invented
17:54:58
jackdaniel
and they had this service, that they had a basic flavor and allowed to have a mixin - so you had a "vanilla" icecream with a "strawberry" mixin
18:33:10
rotateq
baggers has another example with his CEPL videos. sad that the docu isn't up-to-date
18:37:46
rotateq
like how doing it "cleverly" when it gets "wall is you" and you become multiple objects at once
18:38:46
rotateq
and it gets me to think more and more, without CLOS capabilities, how do they even do it in Lua without it becoming too messy? ^^ not to talk about more complex games
18:58:02
rotateq
like when a popular python tool is replaced but the API and superficial look leaves to be the same :)
19:26:47
lisp123
With sly, everytime I exit sly-db, it asks me whether I want to throw to the toplevel (y / n), is there a way to set this to y always?
19:29:35
lisp123
there's a clash between EVIL mode & Sly, so will need to fix that, but otherwise all good
19:48:02
Bike
say we had the code (let ((a (foo))) (map nil #'print a) (aref a 0)), and at some particular time FOO returned a list rather than a vector. how would people feel about an implementation that signaled a type error as soon as the list was returned, i.e. before doing the map?
19:51:05
edgar-rft
I would expect AREF to signal an error (after the MAP), not at the time of the the LET binding
19:54:09
Bike
that's how it usually works now. i'm asking how people would feel if it worked as in the hypothetical.
19:58:49
White_Flame
Bike: would that be because the type inference from aref hoisted up for the whole body?
19:59:38
White_Flame
I think that would be the actual consequence of what "type inference" means. It's about A itself
20:01:14
Bike
it would be inferring backwards from the fact that (aref a 0) is undefined unless a is a vector, yes
20:02:31
Bike
as far as i'm aware, no actual implementation does what i'm describing. they might issue a type warning at compile time if foo is declared to never return a vector, and probably signal an error from aref if it receives a non vector
20:03:25
White_Flame
with high safety and debug, are there runtime warnings when type declared bodies are entered with the wrong value type?
20:12:09
Bike
sbcl will signal an error if there's an explicit type declaration, but not for my example
20:17:05
jeosol
When writing a paper about CL, what is the canonical reference for CLOS in terms of reference citation
20:19:59
jeosol
NotThatRPG: Thanks, I think you are right. I remembered I have a copy of "OOP: The CLOS Perspective" and that is what they cited too for CLOS
20:20:43
NotThatRPG
jeosol: I think it depends on whether you want to give credit to the people who developed CLOS, or just point someone at an explanation of what CLOS Is.
20:21:44
jeosol
good point. But it's more as a reference too for people to understand what I am refering too. Lispers probably does but it's making adding reference appropriately
20:22:29
jeosol
I use SBCL primarily, so not sure if there is doc for SBCL CLOS(?) but I imagine since implementations are mostly compliant, I don't have to cite any specific to SBCL just that higher-level should cover everything
20:23:13
NotThatRPG
So if your readers are not familiar with CLOS the Keene book might be a better citation (or compromise and give both)
20:29:31
jeosol
Keene's book was what I read front to back to understand CLOS so it is definitely useful, guess for non CL folks
20:47:11
Bike
if you want arbitrary element type, you'll have to use (simple-array * (*)) rather than simple-vector (which is (simple-array t (*)))
20:49:45
pjb
Bike: obviously, the bug is in aref: (let ((a (foo))) (map nil #'print a) (elt a 0)) will work for any sequence returned by FOO.
20:50:17
mfiano
struct types. These aren't immediates so I can't really store any simple-array that is not of type T. SBCL says it is a simple-vector
20:54:42
phoe
but arrays of structs can't because of identity issues - I remember discussing that problem some time ago
20:54:46
Bike
it is unlikely that anything but numbers or characters will have specializations, due to how eq is defined. yes.
20:57:42
mfiano
Yes I have cheated and boxed a ub64 return value inside a 0-d array when the caller couldn't inline the function...
21:00:53
mfiano
So how do the type specifiers SIMPLE-VECTOR and (SIMPLE-ARRAY T (*)) differ exactly?
21:07:34
Bike
it's a little bit more complicated. the standard says that a non-adjustable non-displaced array with no fill pointer is a simple array, but it doesn't say that a displaced array or etc is _not_ a simple array. so like, an implementation could say all arrays are simple.
21:18:15
mfiano
Admittedly I am too used to static analysis of SBCL with regard to arrays of varying types, and it maps very well to my mind with what the machine code will look like.
21:27:44
mfiano
I'll probably stick with the runtime check though. I would have to greatly change the load order of my code, as this is for a struct definition that needs to be loaded earlier than the structure-objects the elements of this slot will contain
21:29:38
mfiano
Normally I would use standard-objects, but this is very low-level code that I am doing the early 75% optimization that doesn't take too much time and will more than pay for itself. It's the other 25% that is not going to happen.
21:32:20
mfiano
Which would still be a runtime check. I am getting into a hole I don't want to be in, so simple wins the race.
22:34:08
morganw
Hopefully this is not too much of an annoying beginner question, but I'm following exercises in a book and accidentally made a function which remembers its previous let binding values. Could anyone point me at the mistake? https://pastebin.com/R5x5DBtN
22:39:12
morganw
(count-bases '(a g t a c t c t)) or (count-bases '((g c) (a t) (t a) (t a) (c g))) are the given examples to work with.
22:43:33
morganw
Basically, just count the symbols in either case and return the counts. I thought I was being smart and efficient by modifying the return list in-place, but apparently I'm not that smart... It does work on the first run but somehow the ret list is preserved for the next run.
22:47:15
morganw
(in the chapter about iteration, so the function is meant to be iterative in how it works even when the problem doesn't naturally fit)
22:51:01
rotateq
(loop named count-loop with as = 0 with cs = 0 with gs = 0 with ts = 0 for symbol in list when (eq symbol 'a) do (incf as) when (eq symbol 'c) do (incf cs) when (eq symbol 'g) do (incf gs) when (eq symbol 't) do (incf ts) finally (return-from count-loop (values as cs gs ts)))
22:51:35
rotateq
but watch out, the T will really be seen as the top-value too, but okayish in this case
22:53:12
rotateq
okay, value 'true' but highest system-class top or better ⊤, the T is just by accident similar taken as 'true
22:54:06
morganw
Just to double-check, if you run my function does it also remember the previous runs? (just to check I haven't somehow broken the whole environment)
22:55:24
_death
morganw: you shouldn't modify literals.. the result of '(a g t ...) is a literal. instead, you can use (list 'a 'g ...) or copy the list to create a fresh one, (copy-list '(a g t ...)) .. you can also use copy-tree to copy the sublists in the second one
22:56:41
pillton
morganw: "The consequences are undefined if literal objects (including quoted objects) are destructively modified." from the CLHS entry for QUOTE.
22:57:01
_death
oh, I didn't look at the paste.. the literal you modify is '((a 0) ...) so you can use copy-tree, or simply variables and construct a list when returning
22:57:24
rotateq
i would have said, that better do it with (let ((%a 0) (%c 0) (%g 0) (%t 0)) ...) and you won't get a headache for your SETF forms
23:16:18
rotateq
today i had a thought to something of mine "so this is the prototype for the prototype" :D
23:38:20
morganw
It is that book. But it seems that part of the learning process is being restricted to certain methods in each chapter.
23:43:23
morganw
Order of chapters is first learn about applicative methods, then recursion, then iteration.
23:44:22
morganw
I imagine after this chapter I'd actually be free to pick the most appropriate way to suit the problem. No mention of loop yet though.
23:53:32
NotThatRPG
TBQH I prefer to use the ITERATE macro over LOOP because it's not a separate language like LOOP (also LOOP has some specific defects in terms of conditionals and handling multiple values)
0:15:22
aeth
I don't like ITERATE because it's not LOOP-with-parentheses that people promise when they compare the two
0:15:35
aeth
And if I have to learn it to use it, everyone else will have to learn it to read my code.
0:18:42
aeth
If you don't have to collect (or similar) you can just use CL:COND or whatever, but if you are going to use collect, you suddenly need to use LOOP's if/else system
0:19:28
moon-child
raku and mathematica have gather/take, which are better because they compose with the rest of the language
0:20:00
aeth
again, sounds like something that would require special training, making code that only you can read
0:20:34
aeth
all I want is a hypothetical, e.g. called DO-LOOP, that uses parentheses in a way that makes it fit in... every other feature the same except perhaps for a few things that break the syntax too much
0:22:16
aeth
most of LOOP, parenthesized, could be turned into trailing plists. A few parts couldn't, e.g. the hash table stuff that uses multiple symbols in a row
0:22:42
aeth
once you have things as parenthesized and key/value plists, you have a reason to use it: extensibility
0:24:06
moon-child
sure. It might more might not be _better_, but I think it is definitely not _significantly_ better
0:25:07
aeth
(to anticipate being poked 5 hours from now... OK, a DESTRUCTURING-BIND or an APPLY, depending on how you'd want to do it)
0:26:50
moon-child
(in case anyone cares, here is my loop extensions wishlist: collect into string/array, collect major cells of multi-dimensional array, resulting-in clause, bind multiple values)
0:28:08
aeth
otherwise you have to cons up an intermediate list or give up half of the convenience of the LOOP form
0:28:53
aeth
I usually just PSETF at the start of a DO in the body when I need multiple values iirc.