freenode/#lisp - IRC Chatlog
Search
4:11:11
Bike
the macroexpander function receives the form SECOND as an argument, and you want the value of that form in the macroexpansion
4:15:29
equwal
I often find myself in a situation where I want to change the evaluation of a complicated macro and I just can't seem to get it done.
4:19:54
equwal
Well I have a function like `LET` that has some binds and code, but I want to be able to pass the binds as an environment variable instead of as raw code.
4:23:02
pillton
Do macros related to your LET like operator retrieve something from the environment?
4:23:20
equwal
I was putting together a FORTH in elisp, and it makes sense to call it with something like (eforth ((forth-fn . elisp-fn) ...) forth-code). Once I wrote that I realized that I needed to be able to write (eforth *ENV* forth-code) for code reusability .
4:35:30
equwal
Well I need the expansion of the new eforth-wrapper to be (eforth *env* forth-code) -> (eforth-old <val of env> forth-code)
6:56:09
emaczen
what is the common sense interpretation for BNF {<var>}* ? are the braces and asterisk redundant here?
7:02:17
beach
I guess you have to figure out what variant is used in the document where you found that syntax.
7:03:22
emaczen
https://cs.wmich.edu/~gupta/teaching/cs4850/sumII06/The syntax of C in Backus-Naur form.htm -- can someone help me out here?
10:07:59
schjetne
May I ask a not-strictly Lisp question here, since you'd probably have to be a Lisper to understand what I'm talking about? If so, does anyone have any ideas how to get around the lack of restarts in non-CL exception systems?
10:10:27
schjetne
I'm doing the classic PCL log processing task, where I have files with lines that in turn has fields. If a field fails to parse I want to log an error, but I obviously want to log which file and line it is. So I have the choice between catching at the file level, and then losing every other line and field, or pass filename and line number to the field parsing routines, which means boilerplate and coupling
10:10:30
beach
schjetne: You should be able to implement a near-complete Common Lisp-style condition system in C.
10:10:51
heisig
schjetne: Depends on the language of your choice. C++ -> use Clasp, C -> use ECL, Java -> use ABCL :)
10:12:21
schjetne
I've made a typesafe DSL in Kotlin, which is nice for non-programmers (or programmers not heavily invested in the codebase) since they can get handy completion and typechecking. I suppose it's possible to consume the result of the DSL in ABCL
10:13:38
schjetne
One option is to pass a callback that is the restart to the line parser which in turn passes it to the field parser where the throwing happens
10:15:02
schjetne
But that sort of defeats the purpose of exceptions, when you have to do all kinds of in-band signalling, you're not far from manual error checking like old-fashioned C, or the pure functional languages.
10:16:33
schjetne
So ABCL is an option (but I'm not sure I want to deal with a lot of foreign function calling)
10:17:27
ogamita
schjetne: Ken Pitman has a metalinguistic implementation of the CL condition system including restarts; it could be ported to any language… (theorically).
10:18:30
schjetne
Another option could be to pass the responsibility on the error logging system to know in which file and line the problem happened (and ideally which line in the DSL files too, I wonder if that could be somehow extracted)
10:19:28
schjetne
But that probably means still passing something as explicit parameters, Kotlin lacking dynamic scope.
10:20:21
splittist
If the logger wraps the parser and provides the stream(s) to the parser, then it can track stream progress, perhaps.
10:25:58
schjetne
Maybe I can throw a list of all the exceptions thrown when passing the fields, and then throw a list of all the exceptions thown when parsing the lines, and catch all of them in order at the file level.
10:26:09
no-defun-allowed
David Schmidt was selling a macivory machine with 4 megawords which is about 16 to 20MB of memory if you wanted something modern-ish and not embedded.
10:26:17
v0|d
beach: i tried to compile small ECL binaries back in the day yet faild to run on routers
10:27:16
schjetne
Java exceptions have a notion of a cause, which can be another exception. In this case there would be multiple causes. There would be no way to control the restart behaviour, but it should do the trick.
10:52:30
jackdaniel
v0|d: you may be interested in fact that green threads (coroutines) and delimited continuations will be in next ECL release
10:54:02
jackdaniel
but yes, it will be possible to use both at the same time (i.e a few native threads on which multiple green threads run)
10:56:51
loke`
jackdaniel: That's very intyeresting. What does the API look like? Similar to Scheme?
11:03:11
jackdaniel
loke`: http://hellsgate.pl/files/6d156f6b-user.pdf (navigate to multithread) - this is old ecl documentation from before introduction of native threads (coroutines evaporated in a meantime)
11:04:03
jmercouris
I'm trying to completely eliminate cffi from my application, and if I can't find a suitable replacement for a sqlite wrapper, then I'll have to implement my own pseudo database with files in Lisp :D
11:05:06
Odin-
jmercouris: So, you're basically asking if someone has reimplemented SQLite in Common Lisp?
11:07:10
jackdaniel
if you refuse to use ffi you don't have many options left. you either need a database which you may access via some wire protocol and set up on the machine (i.e postgres), or you serialize/deserialize data
11:07:40
jmercouris
jackdaniel: what are the advantages of cl-store vs just printing and then reading the data structures from a file?
11:07:59
jackdaniel
as of sqlite: it is not a standard but rather sql database engine, so "cl library for sqlite" doesn't make much sense, "clone of sqlite" would be a better phrasing
11:08:08
jmercouris
e.g. let's say I have a list of alists, why not just print them to a file? why might I use cl-store in this case? not trying to argue, trying to understand
11:09:19
jackdaniel
cl-store may serialize for instance hashtables (you'd have to effectively reinvent serialization by yourself if you insist on printing objects to file)
11:09:56
jmercouris
so if I end up serializing things that aren't simple lists of strings or something, then it would be quite useful
11:09:57
jackdaniel
also serialization format may be (not necessarily is!) more compact and faster to read/write to disk / over the network
11:10:14
Odin-
Particularly because there's a bunch of types with no readable form mandated by the standard...
11:10:35
jmercouris
let's say you are developing a system, and you want it to depend on another system
11:10:52
jmercouris
that you are also developing, would you put those in the same repository, or different reposiitories?
11:11:46
Odin-
jmercouris: The thing about SQLite is that it's a full-featured relational database. It can do a _lot_ of neat tricks that aren't obvious if you're just thinking about storing values by key. :p
11:12:09
jackdaniel
as of question what I think you should do: I think you should access sqlite via ffi
11:13:24
jackdaniel
and regarding the second question: keep dependencies in the same repository and update them after testing they work (for builds), but also mainain a separate repository if you want to publish your library i.e on quicklisp
11:14:32
jackdaniel
it depends what you plan to do. if you are interested in providing final builds, then versioning all dependencies makes a lot of sense
11:15:05
jmercouris
Odin-: that's not my issue per se, for example, when I distribute a binary for macOS, I think some users are having issues because the image contains paths to locations of sqlite on my disk (because I installed via macports), things like that
11:16:36
jmercouris
ok, I will see how this part of the codebase evolves, and maybe I will break it out into a library depending on its usefulness/whether I decide to keep sqlite or not
11:17:13
jmercouris
I will look at what kind of data structures I plan on persisting/traversing and decide if it is simple enough to do in just lisp
11:17:26
jmercouris
maybe my needs aren't as great as something a powerful facutly like sqlite provides
11:17:43
Odin-
Hrm. I haven't really dealt with binary images much, but I'd presume there's a way to have the FFI object loading (which shouldn't depend on the exact location, but use system configuration) to happen when the image is loaded?
11:19:02
Odin-
jackdaniel: I'm just leaving space for the possible existence of completely insane implementations. :p
11:19:09
jmercouris
the issue with macOS, is that a user using brew, will not have things in standard locations
11:20:08
jmercouris
I have another question, where can I learn more about how struct comparison is done for a hash table with a :test of equalp?
11:21:00
elderK
Guys, is there a way to get ASDF to spit out an ordered list of files, like, that it loads for some system?
11:23:15
jackdaniel
another super-userful feature I'd love to see is: dump plan into a file which may be loaded without asdf involved to (say) compile the system
11:23:28
jmercouris
jackdaniel: so you are saying that a hash-table in CL will literally traverse a whole list and use equalp as a comparator to find an object?
11:24:35
jmercouris
if the above is true, it is erroneously called a hash table, and should be instead called a dictionary
11:25:50
jackdaniel
equalp was not initially planned to be an option for hash-tables, but a demand has been envisioned
12:07:27
elderK
Guys, are "structures that are literals", like, via make-load-form and stuff, guaranteed to be "coalesced"?
12:08:03
elderK
Are such literals even guaranteed to be like, "interned"? Or could they be reconstructed over and over and over and over.
12:09:13
ogamita
(list #S(point :x 2) #S(point :x 3)) #| --> (#S(point :x 2) #S(point :x 3)) |# mutable structures.
12:15:46
ogamita
elderK: IMO, by default structures are not similar one to the other. This section says that make-load-form defines a similarity between its argument and the object produced by its result, which is necessary for logical consistency. But it says nothing of the similarity between two different structures that happen to have the same slots.
12:16:32
ogamita
elderK: Therefore, AFAICS, CL will do no coalescing of the structures, but make-load-form could return a form that would internalize the structures it would create, and it could return several times the same one.
12:17:13
elderK
ogamita: Well, I use make-load-form already. But, like, you know, it expands to a form that recreates some instance, say.
12:17:28
ogamita
But notice what I said above: unquoted -> no expectation of coalesing or immutability. make-load-form couldn't known if the instance was quoted or not!
12:17:45
elderK
Or ,structure or whatever, I'd prefer it didn't keep calling (make-instance ...) every time that form was executed.
12:18:28
ogamita
So if you implement such a internalizing make-load-form, you should document it clearly that all your structure literals should be considered immutable, quoted or not.
12:22:03
elderK
There's a "top-level" function, read-from. It expects a symbol denoting the type to read, etc.
12:22:16
elderK
Then there are other functions, that don't do type checking and are internalish. They are specialized on type metaobject.
12:23:05
elderK
My macro expands into a call to read-from, rather than %read-from. Because, at that point in the expansion, there is no "visible" metaobject. The macro expander knows the metaobject (and that metaobject /will/ be avilable at runtime)
12:23:24
elderK
So I was thinking I could side-step that read-from, and use %read-from with a 'class literal', patched into the expansion
12:24:06
elderK
All the current way means is that there is some extra type-checking done, and a conversion from the "symbol" to teh "type metaobject"
12:24:26
elderK
(Which should be reasonably cheap: The metaobject is attached to the symbol's plist)
12:25:34
ogamita
jmercouris: putting everything in the same repository is easier to manage, and to keep the versions in sync.
12:27:04
jmercouris
ogamita: that was the idea I had in mind, I was just wondering if it was considered a sin or anything like that
12:35:55
Odin-
(Says the man with documentary evidence Google paid a lawyer to get a seal lifted on a warrant for his data.)
12:38:01
elderK
Guys, is it bad taste to like, generate the exports for a "superpackage" dynamically?
12:38:15
ogamita
what is the result of: (format nil "~8,'0X" (reduce (lambda (n b) (+ (* 256 n) b)) '(1 2 3 4) :initial-value 0))
12:38:15
ogamita
what is the result of: (format nil "~8,'0X" (reduce (lambda (n b) (+ (* 256 n) b)) '(1 2 3 4) :initial-value 0 :from-end t))
12:39:43
ogamita
(defparameter *packlist* '("CL" "FOO" "BAR")) (defpackage "SP" (:use . #.*packlist*) (:export . #.(let (n) (dolist (pack *packlist*) (do-external-symbols (s pack) (push (symbol-name s) n))) n)))
12:48:47
ogamita
Yep. With :from-end t you need to swap the parameters of the function. Ie. the accumulated value changes place.
13:03:52
_death
jmercouris: boolean is (member nil t) .. since type-of will return NULL for NIL, the answer is no
13:07:36
jmercouris
so you would have to do class-of instead of type-of to get what I was originally believing
13:08:00
jmercouris
sorry if its unclear on paper, I know you guys aren't in my head, but I understand now
13:08:55
jackdaniel
http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_g.htm#generalized_boolean
13:09:05
Odin-
jmercouris: Common Lisp's type system is by no means a one-to-one mapping, which can also confuse.
13:09:11
jmercouris
I'm trying to fix the s-xml-rpc library which casts "t" to a string and "nil" to a string when returned by a function instead of a boolean
13:11:33
jmercouris
It seems we are paying tech debt since the dawn of time, here we are running x86 processors...
13:12:01
jackdaniel
sure, I get that (and I'm not complaining), I'm just pointing out that it is a little unfortunate at various occasions
13:33:04
ogamita
and by the way in scheme, else can be redefined, so (cond #f (else 1)) may return #void.
14:04:39
jackdaniel
they usually do, however hash-table class is not guaranteed to be a structure-class (like it is on SBCL) so it may fail on conforming common lisp implementation
14:16:02
jackdaniel
Bike: do I get this part wrong (from make-load-form): "Conforming programs may call make-load-form directly, providing object is a generalized instance of standard-object, structure-object, or condition."?
14:17:07
Bike
i mean, stuff like vectors are dumpable too, but not through make-load-form necessarily
14:19:22
jackdaniel
elderK: it is - until it is insufficient (or too complicated); it is not extensible and hitting undefined behavior with it is not that very hard given how it is specified
14:19:58
elderK
jackdaniel: A lot of the time I find that I can use a let, and a dolist or something inside that, but more often than not, I make use of loop.
14:20:17
elderK
Of course, it proably loops kind of horrible, since I use with = ... for hte same reason I'd use the surrouding let otherwise.
14:21:02
jackdaniel
most of the time I use mapc combined with collect macro, and if I'm in need for something more sophisticated I use DO (and in rare occasions I write a macro which is built on top of DO)
14:26:19
elderK
jackdaniel: I feel this would probably be more complex if I had done it using let and other stuff: https://pastebin.com/BFXHLazL
14:42:53
elderK
_death: Partly - I'm not sure it matters that much. I have subtypes of integer, defined based on binary-integer types.
14:43:22
elderK
I'm using check-type integer in a few places, and I'd rather use check-type <the-actual-binary-integer-type>
14:47:49
_death
elderK: lisp supports wish-based programming.. you can define your own check-type-like macro..
14:54:08
elderK
If I have a make-load-form, and it calls some function in my package, does that function need to be exported from the package?
14:56:50
elderK
The symbol would need to be accessible, since the function I want to call is bound to that.
14:58:40
jmercouris
terminology can be important because it changes how you are thinking about the concepts
15:01:26
elderK
Maybe this is a time where :: would be useful - since the function is only ever going to be called from a macro's expansion.
15:03:56
ogamita
Then indeed, don't export it. As I said, write a public function that will call the internal function.
15:03:57
elderK
It's not meant to be exposed. The only reason I *want* to use it, as part of the form make-load-form returns.
15:04:22
_death
if you have a load form, there are no particular requirements of the symbols in it.. at load time, you need to make sure the package is there and when it is evaluated that they are fbound..
15:05:25
Bike
elderK: the return value of make-load-form is not READ again, so the export status of symbols in it is largely irrelevant
15:07:01
elderK
Bike: Interesting. I thought it would be, so like, you know, it could reconstruct the whatever?
15:08:57
Bike
the form will be evaluated, in some sense. but there's no reason to READ the code in again, it's right there.
15:12:46
elderK
I'm still not 100% on like... the details of make-load-form, and when the form it generates, is evaluated. How many times it is evaluated, etc.