freenode/lisp - IRC Chatlog
Search
0:05:06
npfaro
When I write it to a file with `with-standard-io-syntax` and `prin1`, it comes out like this: (13 #A((17) BASE-CHAR . "ERROR 13, 5621064"))
0:06:06
npfaro
Here's the expression which evaluates to create the '(13 "ERROR 13, xxxx) list: (list (format nil "ERROR ~a, ~a" (car x) (cdr x)))
0:07:42
pfdietz
SBCL's read table has an option for converting strings (on reading) to base strings, if all the characters are base chars. I am wondering if the standard io syntax has that bit set. If not, then to print readably it has to use that weird syntax.
0:09:06
pfdietz
But if you read them and the bit is not set, you should get a string (with element-type CHARACTER) not a base-string (with element-type BASE-CHAR).
0:10:26
pfdietz
Check if the string is of type (array base-char (*)), or of type (array character (*)).
0:18:17
Bike
prin1 prints readably, so it goes through extra effort to prefer stuff like element type that a human reader wouldn't so much care about
0:18:20
pfdietz
You could bind *print-readably* to nil inside the with-standard-io-syntax. Failing that, you could play with pprint dispatch tables to make it do something differently on strings.
0:19:30
Bike
i mean, conceptually if you're using standard io syntax and prin1, you presumably are printing something with the aim of reading it back later
0:38:03
npfaro
that's fair enough, although I intended to dump a form out to a file so that I (and potentially others) could edit it as they please, and then load it back in again
0:50:34
Alfr_
npfaro, you could resort to coercing format's result to a (simple-array character (*)) .
0:53:16
Alfr_
npfaro, prin1 may output anything it likes, as long as it can be read back to recreate something similar to what was printed.
1:20:56
npfaro
I have something like (loop for x in ls when (not (member x other-ls)) for y = (car x) do ...) but I'm getting an error
4:01:07
npfaro
Yeah, the issue is that I have another `for` clause in the loop that uses one of the previous values, and that value cannot be nil
4:03:17
npfaro
or actually i really didn't, now that i'm coming back to it. i'm just looping over a remove-if
4:03:58
White_Flame
ah, so you're not using the restarts to get around the LOOP iteration, that's okay
4:04:45
White_Flame
you could use ignore-errors, which will return NIL for you on error, but adding the debugging FORMAT might be a bit more verbose
4:06:51
npfaro
Is there anyting analogous to a named let in scheme, other than using flet or labels and calling it?
4:09:48
npfaro
not exactly, because you can call the named let with whatever parameters you want just like a recurisve function
4:10:43
npfaro
do isn't exactly as powerful because you have to define a step form for each var instead of being able to specify it in the body
4:13:00
White_Flame
having a specific entry point wiht initializers seems to be the more accepted style than reusing it for the inner loop
4:16:01
White_Flame
at least in SBCL, self-recursive functions compile down to the proper set as needed & jump code
4:32:05
beach
I have seen so many programs become incomprehensible by someone insisting on using tail recursion rather than iteration.
4:34:56
beach
Also, it is usually a bad idea to use idioms from a different language. That goes for programming languages and natural languages alike.
4:36:16
beach
I say, use recursion when recursion is pretty much the only solution, like on trees and graphs. For linear structures like sequences, iteration is usually preferable.
4:50:28
White_Flame
npfaro: I use tail calls a lot, and tend to use self-recursion whenever it goes beyond simple LOOP usage
8:18:09
fiddlerwoaroof
tail-recursion, to me, is a bit like REDUCE: it's great when needed, but it's usually better to use it to make intermediate-level abstractions
8:18:46
fiddlerwoaroof
e.g. I could use REDUCE to do what MAPCAR does, but MAPCAR is less noisy and expresses my intent more clearly
8:21:41
npfaro
tail recursion and a pattern matcher are a "match" made in heaven when it comes to parsing lists
9:30:53
npfaro
is there any way to do a nested loop in a single `loop` form or do you have to do (loop for x do (loop for y do))
11:31:38
daphnis
did something change about the way one should load the code from Practical CL? i tried putting the practicals-... directory into asdf:*central-registry* and doing (asdf:oos 'asdf:load-op :practicals)