freenode/#lisp - IRC Chatlog
Search
7:00:14
fiddlerwoaroof
e.g. if I want to type numbers like 1_000_000, can I do it by saying "ignore _" without re-writing the number reader?
7:11:48
fiddlerwoaroof
Hmm, I guess you could wrap the input stream to contextually suppress underscores
7:12:49
slyrus_
gilberth: do you know if anyone has extended cxml to work with XML Schemas (besides the cxml-rng stuff)?
7:14:14
fiddlerwoaroof
e.g. (let ((*standard-input* (underscore-ignoring-stream *standard-input*))) (loop (print (eval (read *standard-input*)))))
7:14:49
fiddlerwoaroof
where the wrapping stream would peek-char to see if there was an underscore waiting and, if so, not pass it along
7:16:03
gilberth
slyrus_: Sorry, I don't. Althrough I am the original author of cxml, I left it last century. Sorry about that.
7:17:37
gilberth
fiddlerwoaroof: You still want to be able --- in theory --- to read symbols like "foo_bar"?
7:18:24
fiddlerwoaroof
Even then, you could have a little state machine that detects <whitespace><number> and then activates underscore-ignoring mode
7:20:43
fiddlerwoaroof
While, the reason I'm asking is that I'm interested in thinking about the various sorts of incremental changes that can be made to the lisp reader
7:21:19
fiddlerwoaroof
And I happened to see a post about how Haskell has a language extension that lets it accept the Swift/Ruby style numbers with _ as a separator
7:21:21
lieven
good luck. I've always found the chapter about the reader with its constituent and non constituent characters etc one of the scariest in the spec
7:22:10
fiddlerwoaroof
lieven: interesting, I haven't written any really complex reader macros, but I've never found them particularly difficult to implement
7:23:03
gilberth
On the lisp machine the package prefix was a prefix. You could say FOO:(BAR BAZ QUUX)
7:23:28
fiddlerwoaroof
Well, for the first one, couldn't you copy-readtable and get a readtable that that worked for?
7:24:16
lieven
the lisp machine also had an extension for file syntax IIRC. where you could put Syntax: into the first line and it would load the syntax/readtable stuff for you
7:24:23
gilberth
OK. What you are up to? Do you want to serious experiment with new syntax, or do you just want 1_000_000 to work?
7:26:17
fiddlerwoaroof
what sorts of syntax changes it makes easy, which ones it doesn't help with and which it makes hard
7:28:36
fiddlerwoaroof
So, for example, here is your #x read-macro: https://fwoar.co/pastebin/2b5f2890b117d66c487933fdfaa954c6cd870c75.nil.html
7:29:04
gilberth
We can redefine a single character as reader macro easily, like, say, to read "?X" as "(? X)". What you want to do is to dig into the token reader, which is not accessible through the read table.
7:32:18
fiddlerwoaroof
Yeah, I don't mind this sort of problem all that much, though, because it's easy to fix (at the cost of some amount of mis-communication)
7:32:47
fiddlerwoaroof
Things like logical pathnames having an extremely limited character set are harder to work-around
7:34:56
gilberth
Heh, show me one CL implementation, which handles logical pathnames in any sane way anyway.
7:36:40
gilberth
If you want the "_" business: Rewrite the token reader. That is not hard only tendious.
7:37:44
gilberth
Install it to all the constien..., constent.., --- you know what I mean --- characters.
7:40:55
gilberth
fiddlerwoaroof: Take the hard tour. Rewrite the token reader. You only need to get the escaping rules right. You could pass everything, that is not a number to the default reader and be set.
7:44:10
gilberth
"|" and assemble a string. I'd check that for a potential number, strip the "_" and pass it along.
7:48:32
fiddlerwoaroof
Because I'm cheating: I just map over the list and check for any symbols like 1_000_000 and re-read them without the underscores
7:50:15
fiddlerwoaroof
The hard tour sounds like a job for sometime when I'm not about to go to sleep :)
7:51:36
gilberth
That is fine. But: As I said, you only need to get the "\" and "|" escaping rules right. That is not that hard. Assemble a string, check for it being a number, strip "_" if needed and pass the token to the default reader, perhaps by READ-FROM-STRING.
7:53:42
fiddlerwoaroof
What I don't understand is how I'd "activate" the new READ: bind it to all the constituent characters?
7:55:04
gilberth
I'd test it with just entering the new syntax with some random prefix character like "@" or "$", so you will not blow up the whole Lisp until you're set.
8:00:17
gilberth
Oh, and when you delegate, don't forget to install the default read table before calling say READ-FROM-STRING.
8:01:44
gilberth
Sorry, I am a bit passive aggressive right know. Let me correct that: Good morging, splittist. Sorry about that.
14:15:42
jjkola
my quicklisp update became partially borked and now some of the package are still using the old version even though the latest is available and installed
14:17:57
jjkola
when I connect to slime it says the version is 2.20, and also when I connect to other instance where the dists version is latest, slime complains that swank is 2.23 while the currently used is 2.20
14:23:10
jjkola
the reason it became borked was because when updating it complained that ubiquitous could not be found
14:25:29
Xach
jjkola: it seems to me like emacs is loading an old slime through some other means. where does emacs think the function slime-connect is defined?
14:26:33
Xach
Then you will be in slime.el and can check the path to the file with C-x C-f for example
14:27:01
polezaivsani
Hi! Does anybody have tips on what reference (or else) material is good for getting up to speed with subj for somebody having a basic grasp of scheme? I'm thinking to scratch an itch with sbcl planning to learn as i go/fall.
14:27:43
Xach
polezaivsani: first, forget everything you know about scheme when trying to learn how to use CL and SBCL effectively. second, there are many good books on the topic. i like practical common lisp and paradigms of ai programming.
14:27:53
polezaivsani
Bike, thanks i know that. i mentioned scheme to let you know that i have some relevant exp
14:28:15
Xach
i found scheme experience to be harmful rather than helpful, but your experience may vary
14:28:19
Bike
i don't think you have to forget _everything_, but it's definitely a distinct language
14:30:19
Xach
jjkola: hmm! the swank.txt file should point quicklisp-slime-helper to the 2.23 version. i don't know why it is not.
14:31:01
polezaivsani
Oh, i didn't thought of scm experience to pose an issue - i'll keep an eye out for it!
14:33:50
Bike
in lisp the same symbol can name multiple different objects in the same scope, unlike in scheme
14:35:09
polezaivsani
i too worry mostly about recursion, namespaces doesn't seem that big of a deal to me
14:37:15
polezaivsani
thanks for the hints fellows! i heard good praises about PCL and will prob stick with it for now
14:38:00
Bike
the tail recursion thing does imply actual restructuring of program logic more, though.
14:50:33
jackdaniel
when I buffer unfinished lines (from stream-write-string which has a string, start and end parameters) what would be better: storing (list string start end) in internal collection or maybe rather copying the appropriate part of the string to an internal "buffer" string?
14:53:47
jackdaniel
the first approach seems dumb, but otoh it avoids unnecessary copying so it might actually pay off...
14:54:29
jackdaniel
good point, thank you. also when I spoke it aloud I now think I'm in a microptimization tarpit (in a passage which is not a bottleneck)
14:55:08
shka_
jackdaniel: i actually suspect that for short strings copying may be even faster and require less memory
15:15:33
jcowan
I think in practice there is only one implementation that does not do tail recursion, and a few more that don't do arbitrary tail calling. However, it's not CL style to depend on this.
15:17:40
jcowan
One problem with storing "fat pointers" into strings is memory leaks: if you read a 1 MB string from a file and then save a "fat pointer" to just five characters of it, the rest of the 1 MB is basically a memory leak
15:18:42
lieven
jcowan: yes, but things like unwind-protect and similar even in macros may make code that looks tail calling not actually be tail calling
15:19:54
lieven
it took the Scheme people some 20 odd years to correctly define what is meant by tail calls so it's a rather hard problem
15:20:14
jcowan
(I must say that I did not find my knowledge of CL to pose a difficulty in learning Scheme. Although if CL had been my first language, or even my first Lisp, things would probably have been otherwise.)
15:21:51
lieven
the main problem is some people insisting in writing one language in the syntax of another language instead of using a language idiomatically
15:31:02
gendl
i think i can get the seed donors to go along, if we think it will help get closer to the matching target..