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.