freenode/#lisp - IRC Chatlog
Search
11:05:09
splittist
Given the string "/foo/bar/../baz/quux.lisp" I would like to obtain "/foo/baz/quux.lisp", and the obvious generalizations of this scheme. Because the string looks like a pathname I have been looking at various path-related things, but nothing and nobody seems to want to give me what I want. Am I just thinking about this wrong?
11:15:01
splittist
Except that I'm on SBCL (or CCL), and "NB: Since this function does not access the filesystem it will only remove :BACK elements from the path (not :UP elements). Since some lisps, ccl/sbcl/clisp convert ".." in pathnames to :UP, and not :BACK, the actual utility of the function is limited."
11:18:21
splittist
I'll implement it myself. (It is verging on the Left_Pad level of functionality...)
11:26:33
Colleen
splittist: Function pathname-utils:normalize-pathname https://shinmera.github.io/pathname-utils#FUNCTION%20PATHNAME-UTILS%3ANORMALIZE-PATHNAME
11:28:41
Shinmera
that library has been tested on a few implementations at least so I know the stuff is as correct as can be :)
11:37:30
Shinmera
one of the problems is that it can't convert :up, since :up's semantics can differ in the presence of symlinks
11:39:07
splittist
Sure. But since my strings aren't actually pathnames on an OS with symlinks I can treat '..' as :back. (Option would be good (: )
11:41:09
splittist
Odin- and phoe: Yes! I had actually looked at it a while ago but didn't think it would work on the basis of the description of dotdot. 0 for reading comprehension.
13:20:53
didi
What do I use to write a SETF variable that accepts a default value like `getf'? For example, (incf (getf foo :bar 0)) works even if FOO doesn't have the indicator :BAR.
13:35:36
phoe
for GETF, though, you might want to write a more elaborate SETF expansion. There is no #'(SETF GETF), for instance.
14:51:42
_death
didi: actually setf function would not work.. you'll need to use another mechanism (for example defmacro and get-setf-expansion) because FOO may be NIL and GETF will need to modify the binding in that case
14:57:15
didi
_death: I'm using a combination of `defsetf' and `defmethod'. Something like (defsetf getf (place indicator &optional default) (new-value) `(set-getf place indicator value &optional default)), and `set-getf' is a generic function so I can use different classes of PLACE.
15:16:16
phoe
GETF might want to modify a lexical variable. A function is unable to do that; a macro is needed.
15:16:49
phoe
(let ((x 2)) (mutate x) ...) ; in here, MUTATE must be a macro, since a function is unable to affect the binding of lexivar X.
15:17:43
didi
phoe: Ah, interesting. I guess it doesn't affect me in my use case, but I didn't think of that.
15:23:10
jmercouris
pjb: I just want to push their contents to a file as my program is running when launched via spotlight so I can have some hope of discerning *why* it crashed
15:23:10
minion
jmercouris, memo from pjb: stdout/stderr are directed to the same file descriptor as the parent process. So, what does the parent process do to them? (It may redirect them to /dev/null). Inside the child, you can reopen or dup them. What do you want to do?
15:23:39
jmercouris
pjb: because (as I'm sure you know) when you launch via spotlight there is not an easy way to gather stdout of a running program
15:24:30
phoe
didi: if that's the case, then everything's good. DEFUN SETF is going to work well if you do not mutate the binding itself, but e.g. mutate some slots in an instance, or the contents of some cons cell.
15:26:51
pjb
jmercouris: the program itself can reopen its stdout and stderr to a file if that's what you want.
15:29:02
pjb
*standard-output* and *error-output* are different. You can also bind them to file streams, but this doesn't redirect stdout and stderr.
15:30:36
pjb
(setf *standard-output* (open "/tmp/out" :direction :output :if-does-not-exist :create :if-exists :append) *error-output* (open "/tmp/err" :direction :output :if-does-not-exist :create :if-exists :append))
17:23:47
RandomGuy74
how can i automate changing description keyset search order and applying description keys with no mouse input?
20:04:38
Josh_2
Hey, dumb question but what chapter in SICP describes the programming style used in cl-ppcre, I believe It's used for parsing data etc involves conditionally calling lambdas or something
20:10:28
Josh_2
I swear I read someone say that this something is done in SICP, I'm probably wrong though ¯\_(ツ)_/¯
20:34:07
dlowe
You can "compile" a language by transforming it into lambda functions that do the operations
20:45:09
luni
another cool thing is closure conversion, but actually i'm still trying to figure out what to do with continuations
21:47:34
aeth
I'm writing a string pattern matching macro, read-case, which reads characters until one of the branches is taken on literal strings or characters. Eventually, I'll optimize it so e.g. having "abc" and "aeiou" become #\a followed by a recursive macro call on "bc" and "eiou" branches.
21:48:28
aeth
I'm not using a library because I have to customize it to meet my needs of parsing quite a few different languages, but I'm open for ideas. e.g. expressing "0 or more" and "1 or more", or maybe mixing in something like regex or of equivalent power. Or maybe character ranges
21:53:35
aeth
Fare: I mean, yes, actually. I think this should be powerful enough to do BNF->read-case, which then gives me scheme-read, which should give me the Scheme-in-CL.
21:54:09
aeth
pfdietz: Yes, this is essentially a string-case except instead of going string-by-string it's going read-char-by-read-char because either I'm receiving someone's string protocol or I'm reading a prog/config lang's file.
21:54:39
aeth
pfdietz: Currently, when I need to do stuff like this, I do read into temporary strings, but I don't need the inefficiency if I write this macro.
21:55:51
Fare
aeth, if you're going the Scheme way, what does CL buy you compared to say, Gambit or Chez or JS or JVM as the underlying environment?
21:56:51
aeth
Fare: I'm compiling a Scheme into CL, which gives me (1) close to the performance of SBCL when gradually typed as long as the CPS transformation doesn't kill performance and (2) the ability to use any library in quicklisp that doesn't use code-walking macros as long as I can trivially define Scheme procedures/etc. for each CL API
21:57:21
aeth
Fare: So essentially, high-performance+lots-of-libraries while actually doing less work than a from-scratch Scheme
21:57:49
aeth
Yes, the JVM would given even more libraries, but it would be libraries with more of a mismatch. Scheme and CL are similar languages, so wrapped CL should be idiomatic.
21:58:50
aeth
pfdietz: In my testing, ensuring tail recursion via trampoline in a DO loop has 0 performance penalty in SBCL vs. SBCL's own tail recursion (which isn't guaranteed, it depends on optimization levels, so I can't use it)
21:59:03
aeth
pfdietz: So as long as the continuation passing style also has 0 performance penalty or close to it, it will be as fast as SBCL
21:59:06
Fare
SBCL makes a lot of implementation choices that depend on not having call/cc. Implementing call/cc on top of that would probably make it slower than Gambit, Chez, etc.
21:59:42
Fare
Unless you go under the hood an implement some continuation capture deep inside SBCL, which is probably quite possible
22:00:09
aeth
Fare: Initially, it will probably not be as fast as it could be, but hopefully there will be a way to do it eventually.
22:00:13
Fare
(the problem then being—which implicit assumption of which operation will you then be violating)
22:01:50
aeth
pfdietz: I'm implementing Scheme with CL lambdas. The most straightforward way to get call/cc from this is to do a continuation passing style transformation on the lambdas.