freenode/#lisp - IRC Chatlog
Search
4:41:49
remby
well I was considering how to do that in at least 3 languages and I couldn't do it so easily
4:43:05
beach
remby: After you start using Common Lisp, there is typically fewer and fewer reasons to use the languages you knew before.
4:44:01
aeth
remby: in SBCL 2.0.11, SBCL controversially reduced its ARRAY-RANK-LIMIT from 65529 to 256.
4:45:44
aeth
Well, you'll probably run out of memory with a 65529D array, but they didn't try to optimize large dimensional arrays before so they didn't really care
4:47:28
aeth
In some implementations it could be e.g. MOST-POSITIVE-FIXNUM, which can be up to 4611686018427387903 on a 64-bit platform if a FIXNUM is represented as 63 bits (62 bits if treated as unsigned)
4:48:56
Bike
https://github.com/sbcl/sbcl/commit/b628f29e3b3651f8a3a83d28f17b9d514e997849 ah, here's the optimization. simpler than the last time i tried to look up the reason for an sbcl change
4:48:59
aeth
The larger it is, the more likely you'll want to use something sparse rather than just directly using array indices
4:49:39
Bike
you're not going to fit a 257 dimensional array with appreciable dimensions into a cache, i don't think
4:51:40
aeth
heh, 57896044618658097711785492504343953926634992332820282019728792003956564819968 isn't an index. So already that's too many.
4:53:18
aeth
This is a very practical array, though. (apply #'aref (make-array (loop :repeat 255 :collect 1) :initial-element 0) (loop :repeat 255 :collect 0)) ;-)
4:55:52
moon-child
even most apl implementations limit the rank of an array at 15. I can't imagine why anybody would want anything higher than maybe 7 or 8
4:56:58
aeth
the lowest one that "works" for me is (make-array (loop :repeat 61 :collect 2) :element-type 'bit :initial-element 0)
4:58:18
aeth
empirically, if sb-index is not increased, then SBCL could get away with using a cap of 63 and using the rest of the bits for something else
4:59:20
aeth
moon-child: then APL doesn't let you do this: (make-array (make-list 20 :initial-element 2) :element-type 'bit :initial-element 0)
5:25:41
ealfonso
is there a way to quickload some packages in a .lisp file before the reader complains about "package X does not exist"?
5:28:50
White_Flame
oh, the return value will be taken as source code, so: #.(not (ql:quickload ...)) or whatever to eat it
10:05:09
luis
White_Flame: no _need_ for a separate package.lisp file I don't think, just a common convention.
10:06:03
White_Flame
I tend to put exports where things are defined. In such a case, a reevaluated defpackage whines about the empty exports not matching (in sbcl)
12:53:52
jmercouris
and of course I could do `(markup:markup ,(user-interface::object-expression q))
12:54:17
jmercouris
however, I want to just be able to do something like (markup:markup (user-interface::object-expression q))
12:55:40
jmercouris
I want to take an object, and have it emit some SEXP by some function and have that be processed by cl-markup
13:18:40
jmercouris
I wwas thinking evaluate if it is one of my user-interface library forms, otherwise do not
13:20:10
jackdaniel
if I understand correctly, you will need to change the code anyway, so "lot's of code" argument goes away -- in that case what is the problem with using the function markup* in the library?
14:11:33
nij
In the source code, it seems that #'apply is ill-defined. https://bpa.st/NYNBC .. Indeed, the first cond drops you in an infinite loop apparently. And indeed, by copying the code and change each "apply" to "my-apply", I obtained a function #'my-apply that never ends. What's going on here?
14:13:38
edgar-rft
nij: (answer to your clschool question from a few hours ago) if you *need* AND/OR functions, for example as arguments to FUNCALL or APPLY, the the intended way is to use EVERY (function) instead of AND (macro), and SOME (function) instead of OR (macro)
14:14:27
Bike
this definition is for the case where the actual apply function is called, like because it's used as an argument to some higher order function.
14:15:55
phoe
https://github.com/sbcl/sbcl/blob/d4740e38bd4e541c29827d922737147b6813e8b3/src/code/list.lisp#L30
14:16:38
nij
edgar-rft: Oh! Indeed! #'SOME and #'EVERY are almost what I want, only did I need a curried version. I have (finally) implemented one myself.. but will switch back to currying those two standard functions. thanks :)
14:18:44
jackdaniel
it is ugly also from the programmer background - this definition is not technically correct and relies on information that is not available locally
14:19:21
Xach
nij: as kent pitman once said, the model you can use initially is: "built-in functions are given by god"
14:19:35
nij
Let's just talk about CAR as it's much shorter, and the problem seems to be the same :)
14:20:47
jackdaniel
beach: could it be implemented if we exploit the fact, that call-arguments-limit is an integer?
14:22:06
Bike
you can have (apply function arg1 ... argl) as (multiple-value-call function arg1 ... (values-list argl)), which is what sbcl does. and then since multiple-value-call is a special operator it's "fine" in that the magic is on the special operator
14:23:21
jackdaniel
n.b ecl does that to a certain number of arguments (64 if I recall correctly), after that it indeed passes arguments by other means
14:24:09
phoe
and also the namespaces for functions, macros, and specops are actually the same namespace.
14:24:58
phoe
beach noted in the previous discussion that it should have been written differently if this were clean code
14:25:12
Bike
here's a better example for you. write your my-apply, and then do (define-compiler-macro my-apply (function &rest arglist) `(multiple-value-call ,@(butlast arglist) (values-list ,(first (last arglist)))))
14:25:28
Bike
that's pretty close to how sbcl works, if you assume that the compiler macro expansion is always used.
14:25:32
beach
nij: Maybe you prefer the SICL definition of CAR: (defun car (x) (if (consp x) (cleavir-primop:car x) (if (null x) x (error...))))
14:27:41
beach
aeth: You would still have to connect the CAR function to whatever the hardware does.
14:29:50
phoe
the implementation can do whatever it wants while it implements the functionalities provided by symbols in the CL package
14:29:53
beach
nij: When you look at system code, in order to understand it fully, you need to understand how the system does compilation and bootstrapping.
14:29:59
jackdaniel
nij: you may treat it as an implementaiton detail - what Xach quoted is very accurate
14:30:56
nij
But I hope there's a way to tell if something magical is happening, without looking into the source of the implementation.
14:31:13
beach
nij: Again, when you look at system code, in order to understand it fully, you need to understand how the system does compilation and bootstrapping.
14:31:15
phoe
as I said X weeks ago, a Lisp implementation can implement the function CL:+ by sending a question to Mechanical Turk over the internet.
14:31:49
phoe
the list specifying where magics are would need to be maintained by each implementation, and I have no idea of what benefit would be other than for maintainers and implementers.
14:31:55
jackdaniel
nij: from the "outside" behavior operators specified as functions work like functions, period - nothing dirty happens
14:32:02
phoe
nij: yes, studying the implementation and asking people who are knowledgeable in how it works.
14:32:06
jackdaniel
you may spot something magical when you actually look into the implementation code
14:35:51
beach
I think you will find similar "magic" in every implementation. In SICL for instance, you will see (defclass standard-class (...) (...))
14:37:30
nij
But fine, as it's not practical too much, it depends on the implementors if they want to make it clear or not. And that's their personal choice.
14:37:37
phoe
if you see a CL symbol being defined somewhere, it means that you're already in the magic zone
14:38:46
beach
nij: Then, I would have to annotate pretty much every class definition of a system class. That can become quite annoying to read.
14:40:02
Bike
as jackdaniel noted, it's not magic that has any conceivable effect on a conforming lisp program.
14:40:27
Bike
that's why there's no provision for telling you about it. You only need to care if you're curious about how sbcl is written.
14:40:54
beach
nij: My defclass example is "magic" in that the metaclass of standard-class is standard-class so it has to exist in order to be defined this way.
14:41:31
Bike
things that are only special operators ARE magic in a sense that you can actually discern, which is why special-operator-p exists.
14:42:40
nij
beach: I don't understand class yet so I can't say.. but I believe it's doable. (but not practical)
14:44:32
beach
nij: That definition makes perfect sense in that it uses the meaning of well defined operators, so it's ideal that way. But it is not operational for the reason I mentioned. It is the purpose of bootstrapping to make it operational.
14:45:09
beach
nij: The code would have been much less understandable if I had used some specific notation for something that can be perfectly well notated with DEFCLASS.
14:45:22
jackdaniel
n.b that's one of many reasons why programmer is not allowed to redefine operators in cl package (that is - the package is locked)
14:48:24
jackdaniel
(defmacro defmacro (&rest args) (cerror "Are you sure?") (error "Macros are bad for you"))
14:52:45
_death
(handler-bind ((sb-ext:symbol-package-locked-error #'continue)) (defun () () ())) ... (()) => ()
14:54:40
nij
To see what 'car really contains, in particular, i want to see a piece of it as a specop.
14:54:51
jackdaniel
nij: the operator you are looking for is: (defun magical-p (symbol) (eq (find-package 'cl) (symbol-package symbol)))
14:55:41
jackdaniel
there are more magical packages surely, like sicl's primop package, but you know the drill