freenode/lisp - IRC Chatlog
Search
8:47:12
asarch
With Datafly I prepare the SQL statement: (insert-into :students (set= :last_name "Uzumaki" :first_name "Naruto" :address "Ever green st #598, Konoha" (returning :id))
8:47:53
asarch
With the database connection: (with-connection (db :school) (execute (insert-into :students (set= ...
8:48:18
asarch
However, neither of those expression actually returns the id of the newly record created
8:49:17
asarch
Reading the issues about the Datafly project, https://github.com/fukamachi/datafly/issues/7, a fellow says there is an expression to get the id using SQLite3: sqlite3:last-insert-rowid
10:20:44
VincentVega
Is there a way to capture all values that a function returns without specifying the values one by one with multiple-value-bind? Maybe put them in a list or something?
10:40:42
kpoeck_
phoe: cl-postgres seem to reside in postmodern, see https://github.com/marijnh/Postmodern/blob/master/cl-postgres.asd
10:44:52
phoe
kpoeck_: yes, though technically one can use cl-postgres without postmodern, since the latter builds on top of the former
11:31:54
phantomics
Is there a way to change the epsilon used when comparing floats? If I do for example (let ((single-float-epsilon ...)) (= num1 num2)) it fails because single-float-epsilon is a constant
17:01:34
VincentVega
Hmm can I write my own reader macro that start with #+, e.g. #+my-reader or would it conflict with #+sbcl and such?
17:10:53
phoe
named-readtables provides an in-readtable macro that you can use similarly to in-package at the top of the file
18:47:34
pfdietz
I definitely suggest using named-readtables. Also, use readtable changes sparingly.
18:52:55
aeth
reader macros are good if (0) they're dispatch reader macros starting with # like #z; (1) the thing they work on is contained within parentheses like #z() such as #z(42) not #z42; and (2) they expand into a macro that does all of the actual processing
18:54:07
aeth
That is, if you wanted to have literal hash table syntax as #h(...) like some libraries do, have that turn into (hash ...) which actually does the logic. So #h(:foo 42 :bar 43) would just become (hash :foo 42 :bar 43) which in turn does MAKE-HASH-TABLE with the two PSETFs
18:54:53
aeth
But I never write reader macros because virtually all of the time when I start with the first step (writing the regular macro first) that's all I wind up wanting to use.
18:56:20
aeth
Also note that the example macro uses plists. Always use plists. They're so easy to process in macros because you can just use destructuring-bind to treat them as &key arguments, or you can iterate over the plists two at a time (key and value), depending on what you're doing.
19:14:07
flip214
aeth: even better, just use alexandria's (plist-hash-table ...) --- but you might need to specify the test to be used...