freenode/lisp - IRC Chatlog
Search
23:59:43
lxbarbosa
for Lispers that know enough of Haskell, does it offers singular features that Lispers "must know about"? I mean, Lisp has a lot of interesting points that I did not see in .NET/Python, and I want to learn new paradigms and perspectives.
0:00:48
lxbarbosa
Ive read that Haskell is way different of mainstream language but not that different of Lisp
0:03:34
Bike
"must know about" sounds like some kind of weird fad advertisement so i'm not going to say that
0:11:52
lxbarbosa
no-defun-allowed: https://www.reddit.com/r/LispMemes/comments/fq4q2g/i_made_this_for_my_friend_and_thought_i_should/?utm_source=share&utm_medium=web2x
0:12:38
stylewarning
lxbarbosa: I think understanding strictly typed parametric polymorphism and how lazy evaluation affects API boundaries is important
0:14:00
lxbarbosa
stylewarning: hm, cool. I hope there are epub Haskell books, not in the mood of touching lately :D
0:31:22
loli
lxbarbosa: there are tools lisp could easily steal, ADTS are an example (and thus deriving functions over this structure)
0:32:06
loli
probably stealing effect systems would be nice. Though they are quite primitive in Haskell
0:40:33
White_Flame
stylewarning: please try to sell the keyboards to people with a lispm that need one
0:46:30
loli
lxbarbosa: you will! I find it's a nice language, though beware you might just taking harder languages like Coq or F*
3:20:10
sjl
When using &key (foo some-form foo-supplied?) in a destructuring-bind, shouldn't foo-supplied be bound to true if :foo is given in the call and false otherwise?
3:20:21
sjl
like, what am I missing here? https://paste.stevelosh.com/7c301026ece2efc869e5ce253f5ff56f98bbf307
3:23:28
Bike
it uses sb-int:binding* which can bind multiple values, and uses multiple values for the variables
3:23:33
sjl
yeah, it works properly in vanilla lambda lists -- only seems to be an issue in destructuring-bind
8:18:21
amazoniantoad
Hey guys. I'm trying to take two columns and generate a matrix from their multiplication. Could anyone show me how to do this? Currently I'm trying to do (elt (elt matrix i) j) and using setf to set the value. But instead of getting unique values for every cell I wind up getting the exact same row in the matrix
8:19:04
no-defun-allowed
Why are you using an array of arrays? Common Lisp has n-dimensional arrays.
8:19:34
no-defun-allowed
And are you talking about matrix multiplication, element-wise multiplication, or...?
8:21:32
no-defun-allowed
How do you get a 2D array from two 1D arrays? Something like O_i,j = M_i × N_j?
8:24:08
no-defun-allowed
Well, to make a 2 dimensional array, you can use (make-array (list columns rows)), and then (setf (aref <array> column row) value) to set an element of that array.
8:27:26
no-defun-allowed
(Using Petalisp, you could write (defun cross-multiply (a b) (petalisp:α #'* (petalisp:reshape a (petalisp:τ (i) (i 0))) (petalisp:reshape b (petalisp:τ (j) (0 j))))). I don't think Common Lisp is very nice for doing n-dimensional array work without some helper functions.)
8:29:14
phoe
I don't think amazoniantoad is a possible client for petalisp if he's still working on getting the basics of 2D arrays done - maybe in a few months, but not yet
8:29:45
no-defun-allowed
Writing a step between a JIT-compiling parallel array manipulation DSL and using big loops of (setf aref) is left to the reader.
8:46:08
no-defun-allowed
amazoniantoad: "element-wise" would probably refer to O_i = M_i + N_i, if I'm not mistaken.
8:56:37
pjb
Well, you can also use (map 'vector (lambda (x) (map 'vector (lambda (y) (* x y)) v2)) v1) which should be more efficient allocating temp storage, but still O(m*n) temp space.
10:13:30
flip214
Can a compiler macro (or normal macro) get the form(s) it's embedded in? SBCL only would work for that use case.
10:15:48
phoe
flip214: I don't think so. The only thing available is the environment, and that doesn't contain everything.
10:18:47
adlai
flip214: "The value of - is the form that is currently being evaluated by the Lisp read-eval-print loop." (obviously, doesn't work in files)
10:24:26
flip214
I've got a function that asks the user a question - and I'd like to determine whether the outer form wants a string, boolean, or number result
10:24:47
pjb
flip214: it cannot, and this is for the best. This is the best feature of lisp macros, not to be able to know anything about the outer form. This is what makes them secure!
10:25:41
pjb
flip214: however, there is macrolet (and symbol-macrolet), which can be used in the EXPANSION of an outer macro. (and also flet and labels).
10:26:32
flip214
pjb: yeah, and compiler-let, and similar stuff. I'm just wondering whether there's an easier way - #'<= in the outer form requires a number, string= a string, etc.
10:26:44
pjb
flip214: this let you design an outer macro, in which you can have access to a macro. The outer macro can arrange to give the information needed by the inner macro, even if comes from forms outside of the inner macro (but inside the outer macro, of course).
10:27:48
pjb
flip214: that said you are not allowed to shadow the fbinding of symbols in the CL package, or defining compiler-macros on them. So you have two ther reason why you won't be able to do that for <= or string=.
10:30:02
pjb
flip214: now, I don't think there's any guarantee about the environments for macro-expansion and compiler-macro expansion. I don't think you could conformingly pass information from a macro to a compiler-macro. This would have to be checked in the CLHS.
10:30:41
pjb
flip214: but once you have a wrapper macro, you don't really need compiler-macro, and this would allow you to do stuff on forms using symbols in the CL package as operators.
10:32:20
phoe
flip214: the outer form should pass the expected input type to the function, that's the cleanest way I can think of
10:34:59
flip214
phoe: Yeah, that's what I thought, too... I'd just like to avoid having my own code-walker, there are already too many of them ;/
10:35:41
flip214
I hoped that I there's an easy way to see what the outer function is - and then the expected type is easy...
10:36:35
phoe
flip214: if you want a true, absolute hack, use DISSECT at runtime to analyze the stack, figure out which function you were called from, and adjust the typecheck accordingly
10:38:56
flip214
LdBeth: most functions have input/output types already declared, and in the worst case I have to annotate the symbol
10:39:20
phoe
flip214: how about the symbol-macro trick then? you set a symbol-macro in the environment with the expected type that you can then macroexpand in the inner macro
11:10:01
flip214
LdBeth: the query function will only occur within AND, OR, <=, STRING=, and similar stuff. It's not general-purpose.