libera/commonlisp - IRC Chatlog
Search
8:19:34
rendar
every list when evaluated, the first name is the function name, and the rest are the fn args.. but what about in designing some function like the unix command line, where you have optional arguments out from the main list arguments, e.g. consider this: (rm file1 file2 ..) there is some way in CL to specify optinoals args such as (rm --force file1 file2...) ?
8:20:22
rendar
what you think about having oob data for each list argument, e.g. (rm[force] file1 file2 ..)
8:22:41
rendar
pjb, i know, like the unix rm does, but i was thinking to something more deep: attaching data to every list's argument
8:23:40
rendar
pbj for instance, (rm[force] file1 file2) i'm specifying some information to the first arg here
8:24:15
pjb
rendar: well, if you want to be able to specify your parser with such concise notation, you can do it too.
8:26:06
pjb
CL provides you with a standard syntax for lambda-list. If you don't like it, just use &rest args, and write your own parser.
8:35:25
rendar
hayley, let me explain, i'm writing a very minimal lisp interpreter, and my idea is to specify per-token options, e.g. (store a 123[i32])
8:36:16
pjb
You need to specify a lisp reader (different from the CL lisp reader), to use postfix [options].
8:36:32
pjb
This lisp reader can read an object, and attach internally some attributes to each such objects.
8:36:53
hayley
Having integers that use modular arithmetic, and not the usual mathematical notion of an "integer", is often harder on the programmer too.
8:37:45
hayley
Depending on one's idea of "minimal", having multiple different integer types of different sizes is also more complex than just one variable-sized integer type.
8:38:14
pjb
But if you implement it in CL, [i32]1111 cannot return 1111, because there's no way to add attributes to lisp objects. (unless you patch the implementation).
8:38:34
pjb
You will have to return eg. a struct: #S(attributed-object :object 1111 :attributes (i32))
8:39:04
pjb
rendar: but if you are writing an implementation, you can do that internally, and just see 1111.
8:39:59
pjb
(let ((a (read)) (b (read))) (list a (object-attributes a) b (object-attributes b))) [i32]1111 [i16]1111 --> (1111 (i32) 1111 (i16))
8:40:11
rendar
but i have multiple attached data, for instance (store a [fmt:base64;size:223]Qaadwvvw==)
8:40:43
pjb
(let ((a (read)) (b (read))) (list a (object-attributes a) b (object-attributes b))) [fmt:base64;size:223]1111 [i16]1111 --> (1111 (:fmt base64 :size 223) 1111 (i16))
8:40:45
jackdaniel
well, either way this channel is about common lisp, minimal lisp interpreters belong to either #lisp or #lispcafe channels
8:42:12
rendar
so CL like clojure, adopts this notation (:hello world :name John) to have data structures
8:42:56
pjb
the print and read syntax for structure objects, starts with #S and is followed by a list containing the type of structure, and the fields in this format indeed.
8:43:13
pjb
But this is only the s-expression syntax for structures. Internally, they're implemented efficiently.
8:47:22
hayley
I'd still like to know what the application is. (In part because I don't think minimalism should be a goal in itself; it may be a useful property but there is often some other motive in mind.)
9:19:49
beach
rendar: You say that you are writing a Lisp interpreter, but in fact the language is different from Lisp. So why are you writing an interpreter, and what makes it a Lisp interpreter? And what is your reason for not using Common Lisp as the language you interpret?
9:21:35
beach
Is it even homoiconic? I mean, if there is anything that I would think would be an absolute necessity, it's that.
9:35:46
rendar
why not? they just assign some metadata to the token, they don't prevent homiconicity
9:45:31
rendar
beach, consider that i'm very new to lisp, so whatever you have to say will help me to learn more
9:46:16
beach
I didn't have anything particular in mind. Whether it can still be homoiconic depends on what those brackets mean, which is information that I don't have. So I take your word for it.
9:47:05
rendar
beach, well, inside the brackets there will be metadata to help understand the list's item more
9:49:08
rendar
you're telling that data of that particular item, is specified as base64, and has a certain size
9:52:14
rendar
beach, so, it helps the interpreter to interpret that single item better internally, and with this you can also pass optional arguments to functions.. do you see any homoiconicity prevention with this?
15:33:40
beach
So it is not conforming code to do that. SBCL (unfortunately) creates the variable for you, and issues a warning.
15:34:55
beach
As dbotton said, use DEFVAR or DEFPARAMETER to create special variables. Better yet, use LET etc. to create lexical variables.
15:37:32
beach
dbotton: I am sorry to hear that. Because then the books are not describing the Common Lisp language correctly.
15:38:51
beach
And in fact, many examples in the Common Lisp HyperSpec also use SETQ directly. But then, examples are not normative, and it is clear that they were not worked on enough.
15:40:09
dbotton
pjb I am not convinced that they assumed the reader understands, it seems most lisps were ok with it
15:41:45
beach
dbotton: It is a bad idea to allow such things, and we have learned this over the years. A simple typo can create hours of debugging.
15:42:37
beach
dbotton: A similar situation is to automatically create a generic function when a DEFMETHOD form with an unknown name is seen.
15:43:30
AadVersteden[m]
It is handy when doing quick and dirty experimentation on the repl. I like the way it works with warnings. Warnings are real warnings with SBCL.
15:44:48
beach
AadVersteden[m]: If you just get into the habit of using DEFPARAMETER instead, then you get the same effect, AND your code is conforming.
15:45:58
beach
AadVersteden[m]: It is a trade-off as usual. Quick to do sometimes, hours of wasted debugging time some other times.
15:46:25
AadVersteden[m]
I can imagine other people sharing a different opinion, especially due to the length difference between setf and defparameter (which is silly, I know, but some people seem to have their keyboard in a time dilation field)
15:46:54
dbotton
Is there a common object database solution being used these days with CL? Or other non-traditional database?
15:47:26
AadVersteden[m]
It's probably in the spec for compatibility with other lisps, I guessed. For setf that is, for implied defgeneric: no clue.
15:48:14
Fade
calling setq on an indeclared variable seemed to be the style in the seventies in the maclisp days.
15:48:41
Fade
I tend to view pretty much all uses of setq in real code as archaic at best, but a smell for sure.
15:49:08
AadVersteden[m]
dbotton: I constructed some approaches. The broader ecosystem has some interesting approaches. Much would depend on what you're looking for.
16:36:37
dbotton
did it work well? Is there an automatic persistence to disk? ever have data loss issues?
16:42:56
beach
dbotton: Often, I just use PRINT with a special syntax for instances of standard classes, so that I can use READ to read back my entire data structure of the application model.
16:43:53
AadVersteden[m]
<dbotton> "did it work well? Is there an..." <- used it, was fun. Worked. Built something else later.
16:48:41
beach
I do, but dinner is imminent here. Maybe hayley or Bike can help. We use this system for external representations of ASTs in SICL.
16:58:17
Josh_2
otherwise you may make a change to a class definition and nuke your entire database in one go...
17:06:37
Josh_2
I have also found a bug with bknr where previous instances stored in the db do not take a slots :initform when you add new slots to an already existing class
17:07:49
Josh_2
I think for a persistence library for a program like Nyxt then I think it would fit perfectly
18:33:49
nij-
When an error is signaled and unhandled, a debugger is invoked. Backtrace could sometimes be helpful, but not always. For example, the experience today is that the backtrace skips so many steps.. and to manually find out what the problem is it took me one hour.
18:34:17
nij-
Given the rant, the question is why is this the case? Is it a hard problem to make the backtrace better and more informative?
18:35:47
Bike
arranging good backtrace info can be kind of an ordeal for an implementer, it's true. and a lot of optimizations (or really, most) eliminate stuff you'd want to keep for debugging. but probably you had a low debug setting and so it didn't save all possible debug information.
18:35:51
White_Flame
when A calls B, that's a tail call (eg, wont' return back to A), so A's stack frame can just be replaced by B's and isnt' noticeable anymore
18:35:52
nij-
In principle, for any thread at any time, a function calls a function and so on.. so isn't it in general possible to have the backtrace to have every function which is now on the stack?
18:37:00
nij-
White_Flame Is there a way to "turn off" that optimization, just for a faster debugging experience?
18:39:26
Bike
white flame and i meant for you to put the declaration wherever the lack of info is causing problems
18:41:57
White_Flame
if you set it globally, it will affect all library code you load after that, etc
18:42:54
nij-
I'm glad I spent one hour to learn this lesson. Thank you folks! I can foresee this saving me at least 100 hours in my life.
18:44:49
Josh_2
(sb-ext:restrict-compiler-policy 'safety 3 3) (sb-ext:restrict-compiler-policy 'debug 3 3) :sunglasses:
18:44:57
Bike
like i said, a lot of useful optimizations will screw things up for a debugger. the basic point of an optimizing compiler is to turn your code into some completely different code that has the same overall effect without actually performing every operation exactly as written
18:45:30
Josh_2
You could maintain two versions, a test and a live, in the live you can enable safety 1 etc
18:47:03
Josh_2
"How much error checking should be done. If speed, space or compilation-speed is more important than safety, then type checking is weakened (see weakened-type-checks). If safety if 0, then no run time error checking is done. In addition to suppressing type checks, 0 also suppresses argument count checking, unbound-symbol checking and array bounds checks."
18:47:22
Nilby
nij-: to rebuild a system with debugging on: (uiop/lisp-build:with-optimization-settings ('((debug 3) (speed 0))) (asdf-load :your-system-name :force t))
18:49:41
White_Flame
I tend to make macros for things, so I can set a flag, which will generate my declarations one way or the other
18:51:34
hexology
do you use some kind of cross compilation, or do you develop on the same os that you deploy on?
18:52:16
Josh_2
enabling safety 3 debug 3 initially caused me some issues because I was setting slots to incorrect types, but because of the sbcl defaults this was ignored
18:52:25
hexology
im also very curious what people use lisp for in production nowadays. id have a very hard time convincing a manager to let me use lisp at work, even if its something i solely maintain!
18:52:58
nij-
hexology Have you tried writing codes in lisp, and write wrappers for other people to use?
18:54:55
hexology
so instead of an executable it produces a shared library and you can call individual functions therein
18:55:23
hexology
that actually makes a lot of sense. file size is probably big but file sizes on shared libraries can get pretty big in scientific software anyway
18:56:35
hexology
im not a numerical computing expert by any means, but id much rather write scientific/numerical code in lisp than in c++
19:00:53
nij-
So many quant company uses C++ because they are SO FAST (meaning, faster than python).
19:04:13
Bike
a while ago a quant consulted with me a bit about how to improve clojure's compiler to be better at arithmetic like common lisp is.
19:04:19
Josh_2
As far as I'm aware they were using Clojure top to the bottom with a tiny amount of C here and there
19:05:36
hexology
thats interesting, i thought the jvm was known to only be so-so for numerical computing
19:06:40
Bike
the general impression i got from him was that as far as actual numerical performance goes, clojure is middling to terrible, indeed.
19:09:18
White_Flame
many of the algos are very simple accumulators and looking for trigger conditions & thresholds
19:10:12
Josh_2
I do not think that my frens business was numerically intensive, it was more about placing orders in the right place at the right time as fast as possible
19:18:00
nij-
You either pick a lisp team, convert your c team into a lisp team, or export your lisp code to C++ libs.
19:43:59
seok
Josh_2 ah it was when I wanted to map to the method and wasn't sure whether you could map to a macro