freenode/#lisp - IRC Chatlog
Search
13:04:23
shka_
i wask asking about CL:DOUBLE-FLOAT which must have a least 50 bits of precision and 8 bits for exponent
13:05:18
phoe
I assume that SBCL implements floats as IEEE 754 doubles though, which means they take a full 64-bit word
13:09:37
jackdaniel
and that's why single-floats may be much faster on CL, because they may be implemented as immediate objects with a type tag
13:19:44
phoe
32 bits of data leaves plenty of space for tagging information on 64-bit implementations, whereas with fullword data like doubles the compiler and programmer need to exercise and cooperate a lot to prevent boxing
13:38:51
p_l
I wonder if it would be possible (or sensible at all) to somehow pack pointers into NaNs on a CL implementation
15:16:14
korner
so i had been bit confused, i was told to test lisp code i should use sbcl but i cannot quite find how to actually use it
15:16:50
phoe
that's the installation and running part that should get you all the way to the SBCL prompt
15:18:45
beach
korner: You don't typically use Common Lisp the way you use (say) C. It is more common to start a REPL (Read-Eval-Print-Loop) and work from inside the system.
15:19:35
beach
korner: If you plan to develop in Common Lisp the way you do in a typical batch language, you probably won't see the point.
15:20:30
beach
korner: By a batch language, I mean one that takes a source file, turn it into an executable, which you then start from your shell prompt.
15:21:30
phoe
you program in Rust and Haskell by writing code that the compiler then turns into executables
15:21:51
phoe
but you program in Lisp by starting a Lisp image and then modifying it until it contains the program that you want
15:21:57
korner
i noticed though that lisp syntax is lil bit simmiliar to the way i format lua so thats fun
15:23:39
beach
korner: I think there are some YouTube videos that will give you the idea about how we work.
15:23:42
korner
was quite confused what i am even supposed to learn cause there is some common lisp, racket and million other lisps, thought common lisp would be nice starting point
15:24:19
phoe
it's a general-purpose programming language that I personally use for all personal projects I make
15:37:17
contrapunctus
I was wondering today...could I use CL to make a MIDI sequencer? 🤔 It seems to be the exclusive domain of C/C++
15:39:11
beach
Like, do you want to generate the sound yourself from oscillators and/or sample files?
15:40:20
beach
Also, it will depend on how "real-time" you need for it to be. If you fill the sound buffers enough, a GC won't ruin it.
15:41:49
beach
The thing is, most current FLOSS Common Lisp implementations have a GC that is not very good for real-time.
15:50:32
phoe
another possibility is linking against FFI sound generators that don't suffer from GC issues - e.g. cl-collider for SuperCollider
15:50:53
phoe
that's mostly because we don't have soft-real-time GCs in free Common Lisp implementations
15:52:09
beach
So I say, write the thing in Common Lisp entirely. See how it works out. Maybe tweak the parameters for current Common Lisp implementations.
15:52:58
beach
My experience is that it takes some time to write significant applications, and then the context has evolved.
16:01:37
minion
rgherdt: SICL: SICL is a (perhaps futile) attempt to re-implement Common Lisp from scratch, hopefully using improved programming and bootstrapping techniques. See https://github.com/robert-strandh/SICL
16:03:08
phoe
it already had multiple nice effects on the ecosystem even though it's incomplete, so definitely not futile
16:33:55
matzy_
should i be overly concerned if i created a db table in mito using it's classes and i see the table in my sql editor, but the (mito:ensure-table-exists 'mytable) returns NIL?
17:45:17
alandipert
is anyone aware of a pedagogical impl. of multiple values in the spirit of http://home.pipeline.com/~hbaker1/MetaCircular.html? e.g. implemented in terms of other operators
17:46:44
alandipert
uhoh, that link is down. archived: https://web.archive.org/web/20191023160058/http://home.pipeline.com/~hbaker1/MetaCircular.html
17:48:04
alandipert
yeah i gave it a go myself and looks like i arrived at something not far off from his
18:19:07
phoe
this prevents people from using SLOT-VALUE and forces them to uses the accessor functions, which may implement additional logic.
18:19:36
phoe
where "prevents" means "unless they want to type the unholy trio of characters, «::%»"
18:37:27
_death
personally I dislike adorning symbols with strange characters beyond the earmuff convention
18:41:06
_death
btw thanks phoe and beach for today's online meeting.. I got into it a bit late and didn't bother logging in
18:41:41
phoe
but anyway if you'd like to talk about anything for the next meeting, feel free to let me know
18:42:40
phoe
and by "you" I mean "hey #lisp come on the slot's free let's keep the meetings rolling and such"
18:42:52
_death
also, I sometimes (often?) use the convention of giving a protocol-specific prefix to the access functions
18:54:27
pve
Sometimes, I dream of a library that aggregates all the common defclass usage patterns into a set of convenience macros that I could choose from, depending on my mood.
18:55:59
pve
Or one that provides a define-class-construction-kit, to which you can say "Hey, gimme a define-class macro with so-and-so slot and accessor naming scheme that maybe exports the class and its accessors by default, so my fingers don't bleed everytime I want to define a class".
20:10:51
ym
Is a task of implementing arrays with signed (possible negative, in similar way C pointers allows it) index out of standard? Maybe someone knows an example?
20:13:23
ym
Why? I have a sine LUT and it would be nice to have positive values for 0 to pi and negative for 0 to -pi.
20:14:10
Bike
you can just have a function that accesses the lut and takes a possibly negative index as argument, and then it gets the actual index with a subtraction.
20:15:00
Bike
barely anything. also, you could just have a table from 0 to pi and negate it, couldn't you?
20:16:28
Bike
a C array is just a bunch of objects that are contiguous in storage. a lisp array is an actual structure. so lisp arrays don't work like C arrays.
20:17:32
ym
Bike, I can, but I also has a compound type that will fit very well with described LUT access method. But thanks anyway.
20:19:05
_death
because nowadays on much hardware sine computation would be much faster than a memory access
20:24:08
ym
Maybe I have not modern enough hardware, but for me sin always slower than aref from array.
20:29:37
_death
maybe something weird is going on, because modern hardware has fast instructions for computing it
20:35:56
_death
looking at sbcl code it does seem weird that it has #-x86 (def-math-rtn "sin" 1) which supposedly calls the C function
20:42:49
ym
fsin always takes hundreds cycles. Maybe if you implement your own sine on modern Intel's CPU+FPGA chips, that would be same as accessing precalculated value.
20:58:34
elderK
Hey all, I was wondering if anyone had any experience with ASDF package-inferred-systems. If so, how did you feel about them? Did you find they made it easier to manage larger projects? Any alternatives?
21:36:42
pve
elderK: it's a matter of taste, if you're comfortable with juggling exports then it's fine
21:41:11
phoe
How can I define a LIST-OF type using SATISFIES that will only match lists whose all elements are of type TYPE? I want to use it like (typep x '(list-of number))
21:42:04
phoe
I assume that this should expand into (satisfies somepred) - but, given a single argument to the type expander, what should SOMEPRED be?
21:48:06
pve
I remember trying to do that a long time ago too, my conclusion (could be wrong) was that you needed to have some magic to ensure predicates exist for each concrete type you want to check
21:48:23
elderK
pve: How do you handle the case where two modules require something from each other? Say, interfaces.
21:49:18
elderK
I've been playing with Lisp for awhile now but I'm still new to using it in a practical sense :)
21:49:20
phoe
elderK: the easiest is to define a protocol/interface package and have the modules use it
21:50:15
ym
phoe, you first defun somepred so that it accept one argument, then you deftype with (satisfies somepred). Why don't you like the example?
21:51:00
elderK
phoe: Another question is, like, constructors. How do you handle the case of initializing stuff in a new object instance? Say, some members are initialized in a complex way, based on some parameters you set when you create the instance. Do you just have a function that encapsulates that all? Do you use shared-initialize? I'm not sure what the best way is to handle that.
21:51:01
Lycurgus
ACTION forgot the geneology back to mk-defsystem. Also thereis a grovel extension.
21:51:01
phoe
ym: I cannot define a single type named LIST-OF that accepts a type as an argument. I must define LIST-OF-NUMBER, LIST-OF-INTEGER, LIST-OF-SYMBOL, ...
21:51:49
phoe
MAKE-INSTANCE is supposed to be the external interface, because you can arbitrarily complicate the process of instantiating
21:52:07
phoe
by defining methods on INITIALIZE-INSTANCE, REINITIALIZE-INSTANCE, SHARED-INITIALIZE, and/or the two update functions
21:52:28
phoe
in a purely CLOSsy perspective, you should never need any kind of wrapper over MAKE-INSTANCE
21:52:56
elderK
phoe: Okay, so methods on those generics are roughly equivalent to constructors in other languages?
21:53:28
phoe
INITIALIZE-INSTANCE: for new instances. REINITIALIZE-INSTANCE: for old instances that you need to "reinitialize", whatever it means for you.
21:53:46
elderK
How often should we be concerned with reinitialize-instance and such? I rarely see them defined.
21:54:58
phoe
if you don't have a use case for it and don't call it, then you can use the default behavior
21:56:29
phoe
we could cons them onto the beginning of that list I guess, but then suddenly we get (typep (cons type list) '(satisfies list-of-x))
21:57:54
phoe
consing onto the beginning is cheaper than consing at the end and doesn't require the list to be mutated
21:58:20
phoe
if I have a list (1 2 3), I don't want to traverse it and set its last CDR to some type so I get (1 2 3 . MY-AWESOME-TYPE)
22:00:22
ym
Maybe check the type of first element of a list in somepred and compare it's type to other elements type.
22:01:20
elderK
phoe: If I have a class B and I want to create an instance of it in file A (but not use any of its methods), is it wise to have A depend on the file that defines B?
22:01:34
elderK
Or is it not necessary in CL? Since, make-instance just accepts a symbol for the class name?
22:02:01
elderK
I've been going on the hypothesis that the symbol naming the class is namespaced, and so I could import it.
22:06:37
elderK
phoe: If initialize-instance takes care of initializing some slots, how do you ensure that another user instantiating your class, doesn't specify initializers for those slots directly?
22:07:00
elderK
If class A has slots s0 and s1, and s1 is initialized in initialize-instance, how do I prevent the user (make-instance 'A :s1 whatever)
22:08:08
elderK
I've been using keyword symbols for initargs. I didn't think to use an ordinary symbol :)
22:17:41
pve
phoe: neat, are you able to get compile-time warnings with that? (it's late, so I can't reason about that myself now)
23:15:16
phoe
so if we bend the rules and use its output as a boolean, then this code will magically work
23:15:36
phoe
I'll go to sleep now and will use the insight from ym to make a better version tomorrow morning
23:16:14
Bike
i mean, for example, you could have a (list-of cons) and then type-of would return a (cons x y) type depending on what's in the cons
23:16:48
Bike
or one you could actually run into, if you have (list-of simple-vector), but on sbcl (type-of #(1 2 3)) => (simple-vector 3)
23:17:30
Bike
i guess, but that doesn't help if type-of returns something unfavorable for the first element.