freenode/#lisp - IRC Chatlog
Search
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
5:22:07
fe[nl]ix
Eitaro Fukamachi is now accepting sponsorship: https://github.com/sponsors/fukamachi