freenode/#lisp - IRC Chatlog
Search
10:23:53
pjb
Basically, if you save a physical pathname in a lisp image, you failed (because a different user may run the same executable lisp image, so hardwired pathnames may be wrong).
10:24:24
pjb
Since logical pathnames are translated at run-time, you can save them in your sources, your fasls, or your lisp images.
10:24:45
pjb
The only thing you have to remember is that you can only translate from logical to physical, never the other direction.
10:25:04
schweers
its settled, I must learn how to use these beasts :) thanks a lot for the information!
10:25:34
pjb
So when you get a physical pathname at run-time (such as with DIRECTORY, or using an "open" dialog, or given by the user), you must keep it as physical pathname (you can still manipulate all the pathnames with pathname functions).
10:26:16
pjb
The only difficulty there is that there's a lot of implementation and platform specific behavior allowed… So it's delicate to use conformingly.
10:29:34
Shinmera
too bad logical pathnames don't deal well with case and other special characters, among other things.
10:32:23
pjb
(setf (logical-pathname-translations "MY-APP") '(("SUMMER.*" "/opt/my-app/été.*"))) (translate-logical-pathname #P"MY-APP:SUMMER.TXT") #| --> #P"/opt/my-app/été.TXT" |#
10:32:49
pjb
The point of logical pathnames is that you don't polute your sources with implementation and platform specific path literals.
10:33:23
pjb
All those implementation and platform specific physical pathnames, with those cases and special characters variants, are collected into a single place, the logical pathname translation table.
10:34:14
pjb
That said, some implementations may have physical pathnames restrictions that make them unable to represent all the paths of a given platform. Call that a bug.
10:34:33
schweers
do I understand correctly that logical pathnames are there to encode well-known-places which depend on the implementation, the OS, or in some other way on the environment? i.e. obtaining the users home directory would be a valid use of logical pathnames?
10:36:07
pjb
schweers: indeed, in some implementations, #"HOME:" is mapped to (user-homedir-pathname).
10:37:33
schweers
so when reading user specific configs, a logical pathname might translate to ~/.config/ on unix and to … uh … /Users/$USERNAME/.AppData/ on windows? (I don’t use windows much, so I might be wrong here, but I guess you see my point)
10:38:20
pjb
on windows it's even more complex, since appdata and other user specific files are not necessarily in (user-homedir-pathname)…
10:42:45
jmercouris
there's not really a convention in Windows, especially because they support basically all legacy programs
10:43:49
schweers
If I recall correctly MS does have guidelines for these sort of things, but they don’t document it as loudly as they should, as is often the case
10:44:18
Shinmera
schweers: You don't put things into AppData, you put them in AppData\Local, AppData\Roaming, or AppData\LocalLow
10:44:34
schweers
for instance I think its quite bad that still so many programs put their data directly into the users home on unix
10:44:51
jmercouris
yes, that is really annoying, but there is nothing motivating programs from not doing that
10:45:08
schweers
Shinmera: fair enough, as I said, I don’t really use windows ;) Nevertheless, thanks for correcting me
10:45:12
jmercouris
if people really wanted to see a change, a distro would have to take a hard stance and somehow make that harder on their platform or something
10:46:45
jmercouris
I am also 10+ years, but at some point Linux made me very bitter and pushed me to bsd...
10:46:52
schweers
pjb: yes, but that doesn’t cover the majority of software, which is, sadly, not written in lisp
11:00:00
schweers
pjb: what exactly am I supposed to pass to LOGICAL-PATHNAME-TRANSLATIONS? I tried this, but it gave me an error, because the argument is of the wrong type: (logical-pathname-translations (pathname-host *default-pathname-defaults*))
11:01:39
pjb
(setf (logical-pathname-translations "MY-APP") '(("SUMMER.*" "/opt/my-app/été.*"))) (translate-logical-pathname #P"MY-APP:SUMMER.TXT")
11:02:08
pjb
Not necessarily. Some may be provided by the implementation. logical host names such as "SYSTEM" "SYS" "SOURCES" etc…
11:04:13
pjb
so you can access all the files that can be translated by the implementations default rules to map logical pathnames to physical pathnames.
11:08:28
jmercouris
I'm trying to load my system in SBCL, and I am getting a strange error: https://gist.github.com/6d13c14b6005330a69b0b5622d2fd85b
11:09:17
pjb
jmercouris: :mailto is a new option for asdf systems. Perhaps write #+asdf3 :mailto #+asdf3 "foo@bar.baz"
11:10:03
jmercouris
how does one load a recent version of asdf? is it not built into the implementation?
11:12:09
pjb
I download it from https://common-lisp.net/project/asdf/#downloads and then I use (load "asdf.lisp") in my common.lisp rc file. More precisely: (defun load-asdf3 () (unless (member :asdf3 *features*) (load (merge-pathnames #P"src/public/lisp/tools/asdf.lisp" (user-homedir-pathname))))) (load-asdf3)
11:13:10
jmercouris
seems I am using a very old version of sbcl, let me update it first, then I'll try updating asdf by itself if that doesn't suffice
11:20:26
jmercouris
the binaries here are really out of date for darwin: http://www.sbcl.org/platform-table.html
11:34:25
jmercouris
so for example, jumping to definition on setf makes a path of: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_sbcl/sbcl/work/sbcl-1.4.4/src/code/
11:38:22
jmercouris
when you say "install the sources", you don't mean build the source on my system, but rather download it, place it somewhere, and then this will resolve those paths properly with this function?
11:38:59
pjb
If you place them in one of the directories scanned by this function. You can edit this function to include your own paths.
11:42:09
pjb
But since you use your .sbclrc with various versions of sbcl and on different systems, you cannot hardwire the path!
11:46:53
jmercouris
I ended up placing it in /usr/local/source/sbcl to be consistent with the sbcl location
13:02:11
schweers
pjb: I have to bother you once more about logical pathnames. can I have a logical pathname which refers to a file like foo.tar.gz or is this categorically impossible?
13:03:28
pjb
(setf (logical-pathname-translations "MY-APP") '(("FOO-TAR.GZ" "/opt/my-app/archives/foo.tar.gz") ("**;*.*" "/opt/my-app/**/*.*"))) (translate-logical-pathname "MY-APP:FOO-TAR.GZ") #| --> #P"/opt/my-app/archives/foo.tar.gz" |#
13:07:33
schweers
hm, but what if I want to put the .tar.gz into a directory which I obtain via logical paths? I have a translation which gives me a directory where to store the file. But now I need to store a filename with a double suffix in said dir. i.e I have something like this: (setf (logical-pathname-translations "IMPORTER") '(("OUT-DIR;" "/home/schweers/data/"))) (translate-logical-pathname #P"importer:out-dir;foo.tar.gz") ; =>
13:09:06
pjb
(setf (logical-pathname-translations "MY-APP") `(("FOO-TAR.GZ" ,(merge-pathnames "foo.tar.gz" #P"IMPORTER:OUT-DIR;")) ("**;*.*" "/opt/my-app/**/*.*")))
13:09:07
schweers
can I have a second translation to expand into the double suffix and combine them somehow?
13:11:06
schweers
I’ve not yet found a good description of how exactly wildcards work; I guess this is because they work for pathnames in general, not just for logical pathnames. Is this correct?
13:14:57
pjb
(setf (logical-pathname-translations "MY-APP") '(("**;*.TGZ" "/opt/my-app/**/*.tar.gz"))) (translate-logical-pathname #P"MY-APP:FOO.TGZ") #| --> #P"/opt/my-app/FOO.gz" |#
13:15:17
pjb
but notice that in this case, ccl doesn't downcase the name (other implementations would downcase it).
13:15:51
pjb
This means that: logical -> physical is very strong: you cannot access foo.gz unless you make an explicit translation rule for it.
13:16:58
pjb
schweers: also, the rules about case are very clear: the case that should be used is the customary case for the file system where the component is stored. On unix systems, a path can contain components each on a different kind of file system with a different customary case!
13:17:17
pjb
You can mount MS-Windows file systems on MacOS file systems on unix file systems in any order.
13:17:52
pjb
So you can have components of a single path stored on all kinds of file systems. and ;a;b;C;D may have to be translated to A/b/C/d
13:21:51
didi
I remember there is a "standard" on this: If I want to write a macro that iterates over a collection, I should write a macro called DOOBJECTS that expands to a call to a function called CALL-ON-OBJECTS, right? These are the names, aren't they?
13:22:09
jmercouris
jackdaniel: http://thrift.apache.org/docs/install/ these docs are not updated, do you know what the language specific requirements for a lisp install are?
13:25:31
pjb
didi: it relies on the compiler being able to inline the function to generate efficient code.
13:26:18
pjb
Also, often you want to have such a function anyways. (doobjects (o) (print o)) (call-with-objects (function print))
13:27:19
didi
pjb: Oh, you wrote `call-with-objects' instead of `call-on-objects'. Which name people use?
13:29:12
ecraven
how does swank handle an error in another thread than the one communicating with slime?
13:57:44
jmercouris
I mean it generates all of these stubs and this heavy code, doesn't seem designed for standalone applications running on a user system, though I guess it would work just fine
13:59:13
jmercouris
I can see the huge value it provides, but I'm not sure I want to bring it in as a dependency
14:04:28
jmercouris
There's not really a difference, but there is a diffrence in expectations of hardware, how often they'll turn on and off
14:05:10
jmercouris
for example, webservers aren't designed to be stopped and started all the time, they are designed to be long running stable processes
14:05:54
jmercouris
I'm not running a massive organization requiring many different microservices to interact via RPC, so Thrift is not my ideal solution
14:06:41
jmercouris
so while thrift is very cool, a great technology, it is not appropriate for my application
14:10:46
fe[nl]ix
I still think it might be wrong because those serialization libraries used in large organizations tend to have much better error reporting than bare JSON
14:13:18
jmercouris
I'm doing bare xml, but I'll control both ends, so it won't be too bad hopefully
14:16:58
schweers
I’m still having trouble with logical pathnames. I want to substitute a directory (works) and I want to substitute a suffix because I have double suffixes. As far as I understand, if the result of a translation is in turn a logical pathname, it is translated again. So it should be possible to combine these cases. However this doesn’t work for me: https://pastebin.com/yrzWhUfe Any ideas what I’m doing wrong?
14:44:04
jdz
I'm probably insane, and I'm using lisp at work, but I would not call my work "industry".
14:46:16
beach
pmetzger: Damn. How are we going to maintain our productivity advantage if you blab to everyone.
14:50:56
beach
I still remember when my parents were forced to replace the gas stove with an electric one. After seeing how disappointing the electric stove was, my mother said "But I suppose it is more modern".
14:53:08
jdz
I should also refrain from saying anything if I don't have anything of substance to say.
15:11:14
pmetzger
Common lisp hasn't changed much in the intervening decades either, while C++ keeps metastasizing, er, transforming.
15:12:45
schweers
Do you know when the standards effort began? I thought the standards are from 89 and 94, respectively
15:18:19
pmetzger
Actually... CLTL2 was mostly an update of CLTL1 to reflect the tweaks from the ANSI effort. I think. I wasn't really paying attention at the time and it's been thirty years.
15:42:49
jmercouris
they are better than pure "traditional electric" stoves though, I'll give you that, they are more responsive
15:43:38
schweers
ACTION cooks up a nice batch of parentheses on a non-induction stove for everyone to enjoy.
15:51:00
TMA
I have a different experience with gas->electric stove transition than beach reports (for baking that is); electric cooktop of the old style was awful; the gas-top electric-oven combo is close to ideal
15:55:30
schweers
phoe: maybe we should check out some cooking channel and see if they are talking about lisp
16:04:22
jdz
Larry Wall is entitled to see lisp code like that since the rest of the world sees Perl code as line noise.
16:05:37
pmetzger
Perl was a big improvement over the practical alternatives for gluing stuff together 25 years ago. Now the alternatives are a big improvement over perl.
16:06:10
pmetzger
Perl 6 really killed Perl. Weirdly it wasn't so much second systems effect as third or fourth.
16:27:56
comborico1611
Has there been any improvements made to evaltrace notation since 1990? I'm thinking mainly in terms of using it with paper and pencil.
16:41:08
beach
comborico1611: Are you planning to use it in order to learn the evaluation rules of Common Lisp?
16:59:34
comborico1611
beach: Yeah, it is in the book I'm using. Common Lisp: A Gentle Introduction to Symbolic Computation. Gotta go!
16:59:50
CodeOrangutan
comborico1611: Ran across this article today, but honestly not sure that it's an improvement: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.98.5477&rep=rep1&type=pdf
17:00:16
stacksmith
Some of these 'teaching aids' are more complicated to learn than the subject itself...
17:07:06
stacksmith
Wonder how many people bang their head against things like 'evaltrace notation' instead of just learning Lisp.
17:18:57
CodeOrangutan
stacksmith: I'm finding the evaltrace notation useful to understand things like double and triple recursion.
17:51:13
CodeOrangutan
beach: Like FLATTEN FLAT and PRUNE in this code: https://github.com/GustavBertram/lisp-book-exercises/blob/master/on_lisp/4_3_operations_on_lists.lisp
18:01:33
CodeOrangutan
I'm not sure if it's required that the function call itself like so: (func x (func y z)) or if (+ (func x) (func y)) is sufficient for double recursion, but the former form looks like it might qualify as a legit math term.
18:08:30
Pierpa
All this fuss about recursion is only because Fortran 66 did not allow for the same function be active more than once at the same time.
18:09:36
Pierpa
It It was not for this historical accident then then a function would be a function call. Stop.
18:12:03
Bike
recursivity is an important computational property even without computing devices being involved.
18:13:05
jmercouris
as in, I've never had a time where recursion has made a problem of mine significantly easier, or maybe I'm not skilled enough to have seen it
18:13:50
jmercouris
Bike: when I say "good", I mean "applicable", an orange is not "good" at removing bolts, but a socket is
18:14:49
Bike
if you have four differently colored balls, how many different ways can you arrange them in a row?
18:15:18
sukaeto
I gave his book to my wife, and she became confounded by his introduction to lists - how he goes into detail drawing linked list diagrams of cons cells
18:16:00
sukaeto
not because it didn't make sense, but because she became impatient with it. "What's the point of this! Where is he going with this? This is stupid! Is this what you deal with every day at work?"
18:16:57
sukaeto
and it got me thinking that yes, maybe talking about how things are laid out in memory that early on is not only unnecessary, it's actually detrimental
18:17:27
pfdietz
Tree als can be done iteratively but that often means you are implicitly unwinding a recursive algorithm with your own stack.
18:18:18
Bike
shka: there's no "right" order. you just need to ensure that whatever is reading it back later wants the bytes in that order.
18:19:37
jmercouris
I'm not much of a C developer, but I believe different implementations didn't implement floats in the same way
18:20:15
stacksmith
shka: there is no standard for serializing floats in Lisp or C - it is _application_ dependent
18:53:53
didi
Xach: Good question. (values nil nil) sounds appropriate, as the second value represents emptiness.
19:48:47
phoe
The moment you get a segfault, the game is over in general case. Your code might have already written all over your memory and corrupted things that will screw you up later.
19:49:28
phoe
SBCL has error handlers installed for that, so when it segfaults, it drops you into its Lisp debugger in most cases.
19:49:53
phoe
But the fact that your OS detected a segfault is one thing, it's more fun when your system does *not* detect a segfault.
19:51:06
phoe
In other words: welcome to the joys of development with memory-unsafe languages. Please enjoy the view and fasten your seatbSegmentation fault (core dumped)
19:51:35
emaczen
Well yesterday I was learning how CFFI deals with C pointers in terms of getting an address and dereferencing
19:56:00
phoe
translating stuff between languages requires thinking, especially between languages as wildly different as C and Lisp.
19:56:42
phoe
where one is a weakly statically typed static language and the other is a strongly dynamically typed interactive language. and that's just one difference out of many.
19:57:42
emaczen
phoe: One of the reasons why I like Lisp so much is that the grammar makes it immediately obvious
19:59:32
Bike
i suppose the concept of lvalues is a bit like places. i think it makes sense to view & as similar to a macro.
20:03:06
Bike
so if it was in cffi, you'd have like (addressof (mem-aref x y z)) expand to (mem-aptr x y z).
20:07:49
emaczen
One observation I do have though is that I tend to get a lot of segfaults because the C code I am translating is passing pointers to be modified, and then uses this pointer again and I can't tell if it needs dereferenced.
20:09:04
emaczen
Is this a correct observation? There are cases that I can obviously tell where pointers need dereferenced, but it is when these pointers are modified in a function and used later (without looking at the function) nobody can tell they may need dereferenced?
20:10:11
phoe
if you pass a number around, that number is always itself, unless you explicitly incf or decf it using C's ++ or -- operators.
20:11:49
emaczen
In the code I am looking at, config is declared as a pointer, its address is then passed to a function for initialization, and finally it is used like: &config->interface[i]
20:12:20
emaczen
In my lisp code, I had to use mem-ref on config before I could use foreign-slot-value and finally mem-aptr
20:15:24
emaczen
I have: (cffi:mem-aptr (cffi:foreign-slot-value (cffi:mem-ref config) ..) ..) and what I don't understand is why I had to mem-ref when I had previously, foreign-alloced config and then passed it to the initializer
20:16:12
emaczen
(let ((config (cffi:foreign-alloc '(:struct libusb-config-descriptor)))) -- that's what I did
20:19:37
Bike
i thought you had like "struct libusb_config_descriptor* config; initialize(&config);"
20:23:40
Bike
Okay let's think about this for a moment. config, in C, is of type struct libusb_config_descriptor*. Then &config must be of type libusb_config_descriptor**.
20:24:59
Bike
I think you want like (let ((&config (cffi:foreign-alloc '(:pointer (:struct libusb-config-descriptor))))) ...)
20:29:55
Bike
The reason CFFI is conceptually difficult is that it deals with C programs without C's compiler restrictions, which is why all pointers are the same and such. But it still uses some c-like syntax. It can be confusing
20:31:49
Bike
In this situation - the alloc thing - "pointers are all the same" isn't actually so, though.
20:31:56
|3b|
ACTION isn't sure "without ... restrictions" is quite right, since actually keeping track of the types would be a nice feature for correctness :)
20:32:26
Bike
When you (foreign-alloc '(:struct libusb-config-descriptor)) it allocates however many bytes of memory that struct takes up. That could be, for instance, zero, though I assume it isn't
20:32:27
|3b|
problem is more that you can't stack-allocate C things and take address of them, so you can't translate c code directly
20:32:57
Bike
you then pass C a pointer to that memory, and the C program assumes that it can mess with as many bytes pointed to as there are in a pointer
20:33:48
|3b|
(well, maybe you can stack allocate them and take address of them, but you can't /not/ take the address of them and use them directly)
20:35:13
|3b|
would probably help with some of the above problems (assuming correct function definitions), if function wants ** and you pass it *, it could tell you :)
21:26:46
pjb
minion: memo for schweers: "IMPORTER:**;*.tar.gz" is not a logical pathname, because gz is not a valid version number.
21:53:44
pjb
comborico1611: you're asking specifically about evaltrace and stuff, but perhaps you would be interested in cl-stepper?
21:55:30
pjb
comborico1611: https://groups.google.com/forum/#!original/comp.lang.lisp/50k86A63WJA/hMu30bPh6OsJ
22:08:44
pjb
Yes, I'm sure my teachers was looking for something done with pencil and paper whe I wrote 10 for i=1 to 100 : print "I will not expose the ignorance of the faculty." : next i and used the tty instead.
22:10:49
pjb
Come to think of it, that must be the reason why bic stylos are sent by 5, when one bic is usually enough for the whole year… (and notice their convenient hexagonal section).
22:17:30
pjb
phoe: for the whole world, 2+2*2 has no ambiguity. Only those idiots of amercans can find an ambiguity there.