freenode/#lisp - IRC Chatlog
Search
15:27:09
pyc
Given a relative path "foo" what is the best way to convert it to an absolute pathname, example: #p"/home/pyc/project/foo/" ?
15:29:28
jackdaniel
or (make-pathname :name "foo" :defaults *default-pathname-defaults*) if it doesn't
15:32:36
pyc
jackdaniel: yes, I will use the second option because it evaluates what I need when the directory name is a symbolic link to another path.
15:33:52
pyc
just to ensure that I am not falling in the trap of X-Y problem, here is my problem X: given a relative source path "foo" and relative target path "bar", I want to copy all files and folders recursively from "foo" and copy them to "bar".
15:34:26
pyc
so when I start walking through "foo", I get absolute paths for all files and directories found recursively, example, "/home/pyc/project/foo/dir1/file1.txt" and so on.
15:35:21
pyc
so what I am going to do is resolve "foo/" to "/home/pyc/project/foo/" (the prefix), remove that from the source file path to get "dir1/file1.txt" and then append that to "bar" to get the destination path, that is, "bar/dir1/file1.txt"
15:46:49
pyc
What am I doing wrong here: (enough-namestring "/home/pyc/foo/bar" :defaults "/home/pyc/foo/"). Error: invalid number of arguments: 3
15:48:10
Bike
enough-namestring takes an optional parameter for the defaults, not a keyword parameter
15:51:39
pyc
oops! thanks for the help Bike! I am still misinterpreting the docs even though Practical Common Lisp has taught me the difference between keyword and optional.
16:13:17
semz
I'm starting to think ITERATE is largely pointless. It's idiosyncratic with lots of gotchas, hard to extend (beats impossible I guess, but still), and purging it from my code showed that there were maybe two features I used that didn't have a direct LOOP equivalent.
16:15:42
beach
I find mapping works fine when I have the function already made, but not so practical if I have to make up an anonymous function just for the call.
16:58:36
nij
How to bind keys for buffer that's in dired-mode, unbind automatically when dired-mode is off, and bind automatically again if dired-mode is on again?
17:11:25
varjagg
folks who build/deploy lisp applications, how do you handle project dependencies/libraries?
17:14:49
aeth
varjagg: git clone into ~/quicklisp/local-projects (or ln -s there and clone elsewhere) to override the version in Quicklisp while still using Quicklisp to manage dependencies
17:19:55
varjagg
aeth: i'm looking for a reproducible build not involving quicklisp, that means i basically have to get all of ~/quicklisp in there
17:21:08
aeth
you could even query https://github.com/quicklisp/quicklisp-projects for the upstream and (semi-)automate it
17:22:18
aeth
(asdf:system-depends-on (asdf:find-system :foo)) can help but note that ASDF systems don't line up with Quicklisp projects. In general, a Quicklisp project has one or more ASDF systems which in turn has one or more CL packages. And the names don't have to line up.
17:26:17
varjagg
aeth: a practical complication is the build is a part of a broader openembedded/yocto build, it kind of has it's own fetch/configure/build flow
17:26:45
varjagg
so i really just want to write a job that grabs all dependencies in yocto fetch phase
17:30:56
varjag
pyc: qucklisp leverages asdf.. either makes sense depending where you are in dev cycle
17:33:21
pyc
is there a function that can provide only the filenames (as opposed to absolute paths) under a directory?
18:08:46
fitzsim
varjag: that's interesting; I wanted to build a Lisp packages as part of a Yocto build a while ago
18:22:15
pyc
I am able to implement Unix basename like functionality with this code: (make-pathname :name (pathname-name file) :type (pathname-type file)). Does this look alright?
18:33:51
pyc
Is there anyway to do this: (let ((a 1) (b (+ a 1))) (format t "a: ~a; b: ~a~%" a b)). This code of course fails with: The variable A is unbound. But I would like to know if there is a way to achieve this in another way? I want to avoid nesting 'let' within 'let'.
18:35:13
pyc
one question though. why does 'let' exist at all? Can 'lambda' not achieve the same result that 'let' does?
18:37:25
White_Flame
if you assume that the compiler is smart enough to optimize away the function construction & call, then they're equivalent
18:38:02
Bike
LET is a special operator, so an implementation can choose to implement it as a macro for a lambda form, or to handle it directly
18:38:55
White_Flame
pyc: there are a number of ways you could slice CL down to a small number of core forms, and certainly LAMBDA is one of them
18:39:17
White_Flame
but practicality means that the various patterns that one might construct from those get first-class support
18:40:08
White_Flame
and you can't directly make IF a function which calls LAMBDA. You need macro support
18:40:43
White_Flame
because calling a function object evaluates all its parameters, and IF doesn't do that
18:41:15
Bike
there are also some fiddly bits. you could define (defun name lambda-list body) to expand to `(setf (fdefinition ',name) (lambda ,lambda-list ,@body)), except most implementations give function objects names for human inspection, and the latter form may not attach a name
18:41:31
pyc
White_Flame: understood. I don't know much about lambda calculus. I have this question. is it theoretically possible to make something like 'if' or 'when' using lambda calculus?
18:42:33
Bike
pyc: sure. you define true as (lambda (x y) x) and false as (lambda (x y) y), and then (if cond then else) is just (funcall cond then else).
18:42:56
White_Flame
but then you also need some primitive which can make a choice and access 1 of 2 objects to call, which by definition is IF itself, so...
18:43:31
White_Flame
I'm not huge into formal lambda calculus either, but I presume there exists a representation for it
18:44:50
White_Flame
eg, (defun true (a b) a) (defun false (a b) b), such that the IF might call (funcall (funcall bool a b)) given a boolean which is #'true or #'false
18:45:12
White_Flame
but then how does one convert a value into #'true or #'false using pure lambda calc? dunno :)
18:46:59
White_Flame
meaning, at runtime the system has to choose #'true or #'false based on non-boolean inputs
18:47:32
White_Flame
so at this point, one simply turns to practicality and the functionality that the CPU/environment already supplies, regardless of lambda calc, and handwave such things away :)
18:50:04
White_Flame
I shudder to think what the floating point equivalent of church numerals would be
19:06:13
pyc
given a relative directory path say "foo/bar/baz/", what is a good way to extract "baz/" out of it? Is there a pathname function to do that? Looking for something similar to shell's basename foo/bar/baz/.
19:13:42
pyc
Xach: thanks. so I arrived at: (last (pathname-directory "/foo/bar/baz")). It returns "baz". How can I force it to become "baz/" so that it represents a directory path?
19:29:04
Alfr
pyc, as you seem to have decided to go down the pathname rabbit hole w/ all of its "Complicated defaulting behavior", you might consider reading:
20:01:25
warweasle
Is there a lisp web framework that handles two factor authorization and other such things?
23:14:36
jasom
pyc: uiop has a lot of utility functions for dealing with pathnames; try e.g. (uiop:ensure-directory-pathname "baz")
23:57:24
White_Flame
any hints on which of the myriad XML libs to use, preferring a sax style of processing?
0:26:58
jasom
White_Flame: if you do need DTDs &c. CXML is by far the best (but make sure you use a custom entity-resolver if you have untrusted inputs)
0:29:07
White_Flame
a big lack in cliki is no voting/annotation about how the many libs compare relative to each other
0:30:14
jasom
I think "the number of people who read cliki and have used an XML library in the past 10 years" is probably too small for voting to be useful?
0:37:58
jasom
https://plaster.tymoon.eu/view/2319#2319 <-- whichever you decide on, make sure that this doesn't work
0:39:06
jasom
With CXML, that will include the contents of /etc/passwd in the resulting parse (but specifying an entity-resolver that always throws an error will prevent that)
0:40:53
jasom
at least nobody wired an http client into cxml, so out-of-the-box it won't let you make arbitrary http requests, unlike many other XML parsers