freenode/#lisp - IRC Chatlog
Search
22:36:56
phoe
ebrasca: sure thing. There are multiple test frameworks in Lisp that you can use to write automated tests.
22:38:21
dmiles
<Bike> slot locations in that sense are nonnegative integers. so there's a number. [14:23] Disconnected from freenode on Friday January 26th,2018 at 02:01pm. Server disconnect reason: hitchcock.freenode.net
22:44:41
phoe
ebrasca: pick your favorite travel vehicle to Marbela, Spain, and stay there for a few days.
22:47:55
jackdaniel
Malaga is the closest airpoirt as far as I'm aware, and there are buses going out from there every hour 24h to Marbella
22:52:33
jackdaniel
stealing (given you have necessary skills), but it's not socially acceptable ;-)
22:53:27
aeth
ebrasca, jackdaniel: Initial Coin Offering (ICO) seems to be the easiest way people make money these days
22:53:37
pjb
It would have to be improved, and to deal with :type list and vector, but the point here is to show that structure-object can be a subclass of standard-object.
22:56:00
dmiles
pjb: that indeed is what I am doing so i was trying to triage whther or not i created a list of slotnumbers to turn themseves into slotname .. i guess :type list and vector tells us to do it sonner than later
22:59:16
aeth
There are some practical differences with how implementations handle structs that is probably reflected in the assumptions in Lisp code. :type is usually respected in defstruct, and :type is usually ignored in defclass (only CCL seems to do type checking in the latter)
23:00:16
aeth
A while back I was using :type and only CCL would care. You can probably make CLOS always care, with the MOP.
23:01:08
_death
in fact I had an attempt at a patch to help it report better errors https://github.com/death/sbcl/commit/4341538e3e4f62ae111fee2e657d5969322f6b02
23:01:10
dmiles
i have no problem backing my structure with a vector or any sequence.. what i am missing is i've always assumeed there was also a get-slot-value-using-offset type function
23:02:37
dmiles
(since all the sub lisps like LarKC always has such a thing that works on any standard-object but definately on structures)
23:09:31
aeth
_death: (defclass foo () ((bar :initform 0 :accessor bar :type (integer 0 10)))) (let ((foo (make-instance 'foo))) (setf (bar foo) 10f0) (bar foo)) ; works and returns 10.0 in SBCL, ECL, CMUCL, CLISP, and ABCL, but does not work in CCL because it's not of the correct type, with "Condition of type CCL:BAD-SLOT-TYPE"
23:09:32
dmiles
well actualyl consider :type list i suppose they are doing that for some nefarious reason
23:11:20
dmiles
pjb: a little bit.. i know it does what we are talking about.. in fact i am counting on some parts of the system jsut making vectors with Layouts at 0
23:12:09
pjb
ebrasca: nope. in sicl structures are implemented as clos objects, and clos objects are implemented using two vectors IIRC.
23:12:41
pjb
I don't remember if in sicl lisp vectors are implement as clos object, but I would do that, at least for not specialized vectors.
23:14:21
dmiles
but the fact that they :type vector .. i am assuming they are trying to create a secario i already by fdefalt created thus they expected to have 0 slot free for their useage
23:15:33
pjb
dmiles: yes, but :type vector uses plain lisp vectors. The only thing is that you can have :name option (to add the structure type name in the first slot), and :initial-offset, and the fact that you can use :type `(vector ,size) to allocate more than needed slots.
23:16:27
dmiles
(oh .. i secretly roll include and type into the same dohickey ;P .. wasnt sure if that was going to play agaisnt me)
23:17:06
pjb
Well, one problem is that you need to define accessors with the conc-name of the current structure for all the slots that are included with :include.
23:17:35
pjb
So you need to keep track of them. For CLOS you can use the MOP and the superclass, but for :type list and vector, you have to handle it yourself in the defstruct macro.
23:20:56
dmiles
i think i see now.. it might still turn out ok.. if they are supplying the :type list :initial-offset 3 .. what is it they are expecting?
23:22:03
pjb
dmiles: (defstruct (point (:type list) (:initial-offset 3) :named) x y) (make-point :x 1 :y 2) #| --> (nil nil nil point 1 2) |#
23:22:50
aeth
_death: But is there a way to force the type checking on those who don't want safety (well, at least when safety > 0)?
23:23:29
dmiles
pjb: ah, thank you.. i know i should had gotten that from docs but it is more fun sometimes hearing it for sure
23:23:40
_death
aeth: sbcl has some machinery for fine-grained optimization settings, methinks.. but I don't know/remember much
23:24:05
pjb
(defstruct (point (:type (vector 10)) (:initial-offset 3) :named) x y) should be accepted, but apparently it's rejected by clisp, sbcl and ccl…
23:25:54
dmiles
pysically in my system i want to promot doing.. (defstruct (point (:type prolog::point/2)) x y)
23:26:21
aeth
_death: thanks for making me aware of alternatives, but I think for now I'll stick to structs when I want to force type checking.
23:28:46
dmiles
(when prolog code introduces lisp to its innerds ... i been thinking of having iot be seen as a structure that way)
23:30:05
dmiles
(also of course letting lisp see the innerds lisp is actualyl ussing as accesable autodefined structures :P)
23:32:29
dmiles
i been shifting the :initial-offset when someone uses :initial-offset on the :type super (super is shifted)
23:36:21
aeth
The problem I have with type checking at the moment is that I currently architecture my program as users providing data. So type-checking (and possibly other kinds of checks) might happen two or more times because ideally any mistakes should be caught early, but the program also cannot trust the input (someone could have created them another way other than the official way, to avoid the overhead of the checks).
23:36:27
dmiles
right so yes :include is shifting offsets .. but i am glad pjb mentioned that it doesnt shift the :type
23:37:26
aeth
But I think once the data is checked in my program, it could be trusted (even to the point of (safety 0), but I wouldn't do that) unless it's a function that can be redefined (for first class functions I funcall 'foo instead of #'foo based on recommendations here)
23:41:08
aeth
It looks like it would either be (blank blank blank name x y blank blank blank blank) or (name blank blank blank x y ...) or something similar
23:42:26
dmiles
ACTION relizes njow that this .. www.lispworks.com/documentation/lw70/CLHS/Body/m_defstr.htm has examples of :initial-offset but was hoping to see the :name shoved in there
23:44:02
dmiles
then again structs are secretly never really anything more than some synthethic getter/setters over typical list or vetors
23:45:42
dmiles
(make-binop :operator '+ :operand-1 'x :operand-2 5) => (NIL NIL + X 5) so aeth (type-of (make-binop :operator '+ :operand-1 'x :operand-2 5)) is CONS?
23:48:09
pjb
aeth: so, yes, (defstruct (point (:type (vector 10)) (:initial-offset 3) :named) x y) (make-pointm :x 1 :y 2) should return #(nil nil nil point 1 2 nil nil nil nil).
23:48:41
aeth
pjb: Afaik, blank is normally NIL, but blank can be 0 in specialized numeric arrays, but... this is I think undefined behavior, so :initial-element 0 or :initial-element 0f0 or :initial-element 0d0 etc. is probably necessary in those cases for true portability
23:49:48
pjb
aeth: obviously, structures cannot use specialized arrays. But an implementation could allow it, if you don't pass :named and if all the slots have the same type.
23:50:12
pjb
In that case, indeed, a different value would have to be used in the unintialized slots.
23:52:04
aeth
I do like that Lisps do set things to NIL, (coerce 0 'whatever-number-type), or (code-char 0) though. Or at least, tend to.
0:02:26
aeth
It would be nice if there was a way to do heterogeneous but typed arrays, though. Where e.g. the first element is a symbol and the next 3 are single-float.
0:31:58
holycow
okay so now i have a spreadsheet with 30 000 rows and rows counted. calc counts the rows, inserts a line and prints total and groups by date so i get total number of entries per day.
0:32:55
holycow
any suggestions on how to collect all of the subtotals and pull them all into a separate worksheet? i'm not googling an obvious way to do something like that.
0:50:49
holycow
hmm, although, strangely using lisp with a csv export of the data might just be the fastest
0:54:49
pjb
(let ((typed-vector (cons #(foo 1 2 3) #(symbol fixnum fixnum fixnum)))) (setf (tvref typed-vector 1) 4.4)) => type-error
0:55:22
pjb
aeth: don't ask that the implementation provides all the silly ideas you have (unless you're the implementor!)
0:57:11
aeth
then *only* tvref would be required, since the implementation will probably handle the types for me when using a struct
0:58:51
aeth
It would also print as expected with a defmethod print-object on the type created by the struct
1:03:07
aeth
(defstruct typed-vector-fixnum (name :name :type symbol) (slot-0 0 :type fixnum) (slot-1 0 :type fixnum) (slot-2 0 :type fixnum))
1:03:10
aeth
(defmethod print-object ((object typed-vector-fixnum) stream) (format stream "#(~A ~D ~D ~D)" (typed-vector-fixnum-name object) (typed-vector-fixnum-slot-0 object) (typed-vector-fixnum-slot-1 object) (typed-vector-fixnum-slot-2 object)))
1:03:34
aeth
pjb: Just that, with an aditional aref-like function also defined. Fairly easy to generate with macros, too. Might only be efficient for short things. ^
1:05:50
aeth
And tvref could be defined as an inline specialization via specialization-store with the new type definition creating a new defspecialization in addition to the defstruct and the print-object.
1:15:46
pjb
aeth: note that if you write: (defstruct (typed-vector-fixnum (:type vector)) (name :name :type symbol) (slot-0 0 :type fixnum) (slot-1 0 :type fixnum) (slot-2 0 :type fixnum)) then the structure "accessors" should still check the types, but indeed, you would need a custom aref for those vectors.
1:16:28
pjb
aeth: but for this custom aref, you will need to keep the type of each slot, unless you hardwire it in a aref specific to each structure type.
1:18:26
aeth
pjb: specialization-store can handle the dispatch. Efficient inline dispatch if you keep the type, runtime dispatch if it's generic. I don't think specializations can handle setters, though, which would be problematic for an accessor like a fooref in specialization-store, which will probably require a getter and a setter. That may be patchable depending on the architecture, though, and a patch would probably be simpler than a new scheme wit
1:19:19
aeth
pjb: I think the main issue is that most of the novel things will be stored in T arrays or T cons cells or T hash-tables, which *will* lose the type information.
1:19:54
aeth
If implementors would have to address any of that, that is what they'd have to address, not any specific data structure.
1:21:23
aeth
T cons cells are easy to replace with typed cons cells because of their simplicity. Just do the struct approach again. Arrays and hash-tables would be trickier.
1:23:37
aeth
As soon as you want to put this faked-via-structs typed vector into a long array (e.g. 1024 long)... I think that's where this falls apart.
2:46:54
pjb
aeth: I don't understand this fad for specialized arrays. Using T everywhere means that the same code is used everywhere all the time, therefore way fewer I-cache lines are needed, therefore the program runs much faster.
2:57:01
aeth
pjb: I don't commonly write code actually inteded for T. I generally write code that either gets type inferred well or code that gets type inferred poorly and can benefit from type declarations. The latter case is generally numbers and arrays. (Type declarations or check-type in the former case would just move the type error to the top of the function instead of somewhere else, and not actually improve the compilation.)
2:58:01
aeth
(defun foo (x) (car x)) ; x is going to have to be a list or a type error, and SBCL knows this
3:06:29
aeth
Oh, and afaik most of the second case can probably be avoided if everything was put it one compilation-unit (e.g. one file).
3:08:37
White_Flame
pjb: i-cache pressure would have an upper bound by type. d-cache pressure is by footprint, which I'd think would hurt more for non-specialized
3:10:59
White_Flame
really, the only thing that makes sense for specialization is unboxed numeric types, IMO
3:12:08
aeth
White_Flame: What about structs that primarily contain unboxed numeric types? They could also benefit from specialization.
3:13:04
White_Flame
hmm, yeah I guess. As long as the types are known by whoever's accessing the array
3:13:22
aeth
Also, arrays and structs can unbox things that are normally boxed, e.g. double-float and even (unsigned-byte 64)
4:08:46
red-dot
Is anyone aware of CL libraries for working with Google cloud? With the exception of https://github.com/death/gcm, nothing seems to turn up in searches.
4:24:36
p_l
red-dot: nothing available at the moment, should be quite quickly doable as they all follow REST quite well
4:41:14
red-dot
For anyone interested in Google APIs in Swagger (Google has its own version of Swagger): https://groups.google.com/forum/#!topic/google-apis-discovery/NdreD8_xWOk
4:48:04
red-dot
Finally, for someone wanting to generate a client via Swagger, this seem to be the only option out there for CL: https://github.com/incjung/cl-swagger-codegen
5:32:11
stylewarning
Open sourced MAGICL, a linear algebra library. Definitely a WIP and the high-level interface is rough around the edges. Please send improvements, PRs, issues, or design suggestions! https://github.com/rigetticomputing/magicl
5:55:38
aeth
stylewarning: Did your team consider using :downcase help with the readability of your generated files like blas-cffi.lisp?
6:23:46
|3b|
ACTION usually tries to make generated code look nice if possible, going to see it from M-. often enough :)
10:09:58
aeth
return-from works in functions, apparently. And apparently this works: (defun foo () (return-from foo 42) "Hi")
10:15:18
Shinmera
_death: Confusing how? And yes, there's no lisp type, just a common-lisp one. I'll see about completion.
10:17:03
aeth
paule32: Use cond and and instead of two ifs and then you can get rid of the return-froms and just use the implicit return without changing really anything else in your structure.
10:19:59
Shinmera
beach: I'm more astounded that people in here don't learn that helping in this case is pointless and only increases overall suffering.
10:27:40
stylewarning
aeth: it has been preferable to do things like (defun foo () (when condition (return-from foo 42)) [ ... long logic code ... ])
10:29:04
aeth
shrdlu68: This should probably be taken to #clnoobs where the exact same question was asked by paule32
10:31:26
aeth
stylewarning: off topic here, but there is a ##python-friendly that is "like #python, but friendlier" according to its topic
10:32:09
shrdlu68
return-from is a simple way to exit from necessarily complex functions with a given value.
10:32:12
aeth
This is an endless source of wisdom (as long as the topic of the channel is SEOed enough). http://irc.netsplit.de/channels/?net=freenode
10:32:28
beach
Shinmera: I am willing to give them the benefit of the doubt, assuming they haven't seen the recurring behavior.
10:33:07
stylewarning
I wonder if I can hijack beach's compiler work to help make static analyzers for code style
10:33:41
Shinmera
stylewarning: I wouldn't call it "hijack", I'm pretty sure such a thing is within his interests.