freenode/#lisp - IRC Chatlog
Search
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.
22:02:59
aeth
Fare: Proper tail calls are via a trampoline, i.e. return a thunk in a DO loop. This has no performance penalty in SBCL over SBCL's tail recursion which I can't rely on.
22:03:45
Fare
also, if you have continuations, please do delimited control, not (just) global control.
22:04:02
pfdietz
It will be mildly hilarious if this ends more performant than the dedicated schemes.
22:04:33
aeth
pfdietz: That is the intent, actually. This isn't very different from compiling to C, except this (CL) is a language with less mismatch in semantics so the compiler should be able to optimize more
22:05:14
aeth
My intent is to "launch" on February 29th so that its birthday can be on a leap day. I almost did that 4 years ago, but delays came up and I put the project aside for other things. But I don't want to miss this opportunity again.
22:06:14
Fare
does your Scheme have a name? I had names for Schemes... my favorite is Agley, as gang the best laid schemes of mice and men.
22:06:46
aeth
I have an idea from an old HN thread, but it depends on if someone took the domains yet or not. That's why I won't say it, either.
22:11:00
aeth
Anyway, my first step is read-case, that should give me enough to handle the BNF that is in r7rs.pdf, which gives me the complete scheme-read. Then I'll have to find a CPS scheme, and after that, that's like 80% of a Scheme since I alrady have most of the Scheme->CL mappings written (e.g. + is just +, car is almost car but (car '()) in Scheme is an error, etc.).
22:12:23
aeth
A lot of the edge cases are already solved, like #f represented as a CL symbol, where CL functions are either wrapped as a procedure (nil is '()) or a predicate (nil is turned into #f which is something like 'false)
22:12:52
no-defun-allowed
We're considering the name Kaplin Scheme, but that is going to be a long way away. (Kaplin tried to assassinate Lenin, which makes for a funny contrast to Stalin as a heavy inlining compiler.)
22:13:08
aeth
And the case-sensitivity of Scheme is solved by inverting the case in the Scheme reader, i.e. scheme:foo is SCHEME:FOO, but scheme:FoO is SCHEME:fOo, so in the common case, there's trivial CL<->Scheme interop, but Scheme remains case sensitive
22:16:37
aeth
no-defun-allowed: As for the interactivity, I would ideally have the same interactive development semantics as SLIME, ideally even accessing it through SLIME. Continuations might make this complicated because "stale" bindings matter more
22:17:43
aeth
no-defun-allowed: Also, the global Scheme binding environment is a bit complicated because there are no lexical globals in most CLs. Portable CL has dynamic/special globals, and non-portable CL extensions (e.g. in SBCL) tend to provide globals where you can't locally override them at all
22:19:27
aeth
On the other hand, Lisp-1 vs. Lisp-2 is no deal at all because a Lisp-1 inside of a Lisp-2 is just a Lisp where you store (unnamed) lambdas in the variable namespace.
22:22:49
aeth
pfdietz: Thanks! Barring complications, I'll have something on the 29th, even if it's not complete. SCHEME-READ should be done. Continuations might not be. Hygienic macros, probably won't be ready. As for a few really weird procedures like rationalize, they'll almost certainly not be ready in time.
22:24:41
aeth
A mutable "global" (within the Scheme) binding environment (which I think no-defun-allowed wants?) is going to be tricky and might not be there initially. I might also have to pay close attention to the equality testing predicates to ensure that the semantics match the r7rs spec.
22:28:22
aeth
Excluding a macro system and call/cc, I've been sitting on like 80% of a Scheme for years, just with an incomplete, not general enough read, which is why I'm trying to write a pattern-matching read-case that is equally as powerful as the BNF used in r7rs.pdf, guaranteeing complete reading.
22:31:45
aeth
Oh, one final thing... no CLOS wrapping on launch (but generic functions are just functions, so they can still be wrapped like any other function if DEFMETHODs are defined in CL) and no guarantee of keyword support at launch, either.
22:34:12
aeth
I'm targeting r7rs small, which isn't much. There will be a full CL wrapping at some later point, for things like GETHASH and MAKE-HASH-TABLE, as well as AREF and MAKE-ARRAY, probably the most interesting data structure features of CL
22:35:56
reepca
I'm in a pickle with pathnames again... I've got the pathname of a temporary file from uiop/stream:with-temporary-file, and I want to rename it to a different pathname. Unfortunately uiop has created the pathname with :type "tmp", and I'd like to rename it to a file that doesn't have a type. But rename-file fills in any nil components with the corresponding components from the source pathname...
22:36:49
reepca
so as far as I can see, there's actually no way to rename a pathname that has a non-nil type to one with a nil type
22:40:13
reepca
I guess with-temporary-file does provide an option for controlling the type, so I can work around that, but it does seem strange
22:46:30
reepca
hm, actually it seems with-temporary-file doesn't distinguish between the keyword-argument-is-nil and keyword-argument-not-provided cases...
22:50:17
Fare
reepca: the problem with nil vs :unspecified is that not all implementations support :unspecified as a pathname component
23:04:33
reepca
Fare: I looked at the code, turns out there's a bit of a bug with with-temporary-file that isn't present with call-with-temporary-file
23:05:10
reepca
with-temporary-file checks whether :type is nil at macroexpansion time and omits the argument if it is
23:05:48
jcowan
I'm particularly interested in how Scheme looks to CL. Do you have to funcall everything, or is symbol-function set for free when possible?
23:06:17
reepca
but this means that the distinction between supplied-as-nil and not-supplied is lost, and not-supplied is the only case that can be expressed using with-temporary-file