freenode/#lisp - IRC Chatlog
Search
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.
5:21:56
aeth
Well, you can always write your own. The closer your syntax is to CL's, the easier it is to write it in CL.
5:25:58
beach
vegai: So is the plan to learn enough Common Lisp to tell whether you can stop searching?
5:33:11
aeth
People have done everything from webdev to gamedev so there's quite the range of projects
6:02:07
vegai
strong repl/dynamic programming; static types (optional or not); performance; stability; non-ambiguous syntax; standard with more than 1 implementation
6:17:49
seok
this isn't lisp related, but how would I scan my local ports to see which ports are being used by applications?
6:20:18
flip214_
seok: but if you use 0 as port number, the kernel will allocate an available one for you
6:20:44
beach
vegai: The Common Lisp language exposes the structure of the internal representation of code. In most languages, that structure would be internal to the compiler, and different for each compiler. As a consequence, the Common Lisp special operators (corresponding to fixed syntactic constructs in other languages, like loops, assignments, conditionals, etc.) is defined in terms of what goes where in the list that represent the
6:51:44
praiseallah88
sun is not doing Allah is doing to accept Islam say that i bear witness that there is no deity worthy of worship except Allah and Muhammad peace be upon him is his slave and messenger