freenode/lisp - IRC Chatlog
Search
0:12:00
aeth
make-array with an :initial-element and if that's too verbose (it often is) you can just define a trivial inline function to do it
0:13:39
aeth
They could be more space-efficient and provide the compiler's type inference more information if you give them an :element-type, e.g. (make-array 3 :element-type 'single-float :initial-element 0f0)
0:14:30
aeth
element-type is only going to work for certain kinds of numbers and characters, like e.g. (unsigned-byte 8). Besides characters and bits, it's implementation specific, but almost all of them will have single-float, double-float, and various byte sizes (especially 8, 16, 32, and 64) that are signed and unsigned
0:16:08
aeth
by default, and if you give it an invalid type, it'll just be a T array, i.e. holds anything
0:16:45
aeth
initial-contents is another useful feature, e.g. (make-array 3 :element-type 'single-float :initial-contents '(1f0 2f0 3f0)) => #(1.0 2.0 3.0)
2:14:53
manualcrank
how do you quell the "the default initial element 0 is not .." for uninitialized specialized arrays?
2:18:31
manualcrank
if you give an initial-element here it'll just be 10 references to the same element
2:21:59
aeth
manualcrank: (upgraded-array-element-type '(array fixnum (*))) is probably going to be T... what implementation are you using to get that error/warning/note, though?
2:26:55
aeth
I guess it's one of those things that only exists within function scope because that information is going to be lost outside of that function because it's just a simple-vector, i.e. a vector containing T
2:27:18
aeth
You could try (make-array 10 :element-type '(array fixnum (*)) :initial-element (make-array 0 :element-type 'fixnum)) or you could also try using :initial-contents
2:27:33
Bike
the warning only shows up in a file because if you just put a make-array call in the repl it won't compile anything.
2:31:16
Bike
i think sbcl should just take out the warning, really... reading an element without writing it first is UB anyway
2:38:01
manualcrank
i assumed if the compiler knew i was processing an an array of fixnum arrays it would generate more efficient code?
2:39:04
Bike
you can declare the type of elements in an array with type declarations, rather than specifying :element-type, which is more fundamentally about the runtime
2:45:34
aeth
manualcrank: If you wanted more efficient SBCL code here, you could consider a struct with typed slots or a 2D array.
2:49:43
manualcrank
adjacency list representation -- each element of the array is an adjustable array
2:52:11
manualcrank
i use vector-push-extend to add vertices. A 2d array would be very wasteful in that case, graph is large but not usually dense
3:01:22
manualcrank
i do declare array type when it's a parameter, but not being a fan of DECLARE (aesthetics) i had been using element-type at the point of creation (thinking the effect would be the same)
3:08:09
Bike
it might work out the same, provided you never pass the array to a function or antyhing
3:13:19
minion
The URL https://gitlab.common-lisp.net/users/sign_in?secret=2292e1bb will be valid until 03:15 UTC.
6:25:03
tourjin
when I run clisp in wsl I get this errors. Cannot map memory to address 0x800983608000 .
6:25:03
tourjin
[/build/clisp-u7VYrq/clisp-2.49.20170913/src/spvw_mmap.d:498] errno = 22 (Segmentation fault (core dumped)
6:39:18
beach
tourjin: You probably also don't get many answers because CLISP is not the most commonly used implementation among #lisp participants.
6:43:35
no-defun-allowed
tourjin: I would think it's an odd bug created by memory mapping trickery some Lisp implementations use.
6:44:00
no-defun-allowed
WSL still runs under the Windows kernel and tries its best to map POSIX-y calls to Windows, and I would expect some impedance issues.
7:20:36
pjb
jiny: in that case, it can be expected indeed that strange things occur with memory and mmap. A feature request should be posted on the clisp github to ask support for wsl. But this will probably be very low priority, so you better provide a patch with a PR…
7:25:18
jiny
thanks pjb . I installed gnu clisp . it seems to work fine. but clisp on wsl crashes when I run it. and I use low version of windows10 home edition. so I cant install new wsl2 version on my computer.
7:26:13
pjb
jiny: since sbcl already solved the problem, you might be able to provide a working patch easily enough.
7:28:22
red-dot
good luck with sbcl on Windows... perhaps WSL will work. For normal Windows, this just isn't a platform they care about.
7:28:48
red-dot
Say, does anyone know how to contact the gitlab.common-lisp.net folks? They sign up system is a bit broken
7:29:00
pjb
jiny: the thing is that sbcl understood the problem and corrected it for sbcl. So reading this patch you will be able to understand it, and to build a patch for any implementation, including clisp.
10:57:26
DrDuck
I saw Alan Kay alluring to some stuff Mccarthy wrote 50 years ago and essentually said it makes Mondads look like a cludge and waste of time
10:58:31
DrDuck
In his 'Situations, Actions, and Causal Laws' part of his 'Programs With Common Sense' paper
11:00:21
DrDuck
so i really have half a understanding of all of this. what did alan kay mean by that statement?
11:18:27
pjb
So monads are just a bad and awkward implementation of objects in purely functional programming languages.
11:22:47
White_Flame
monads don't really implement objects, in the I/O mutation hiding sense. They externalize them from the language
11:24:12
White_Flame
it merely is an interface to something external, where the interface itself is immutable
11:25:26
White_Flame
and of course, that was the main thrust of why monads were added to haskell, and then their other uses were promoted as well
11:29:27
DrDuck
so is there anything in common lisp that's as expressive/powerful as haskell typeclasses?
11:30:47
LdBeth
Typeclass is no more than a sophisticated ad hoc overloading => make ad hoc polymorphism less ad hoc