libera/#lisp - IRC Chatlog
Search
21:39:02
prokhor__
Shark8, White_Flame: thx for the discussion btw, didnt have such a good talk in a while...
21:42:49
Shark8
prokhor__, I had a good talk, too; last year I was in the middle of going down the IR rabbit-hole, thinking about several things: how it would have been better if (e.g.) WebAssembly had done a more parallel-friendly design [akin to the conclusion in the Guy Steele vid], how to design the IR to be storable/decomposable in a DB, and how to manipulate such a DB-based IR.
21:48:46
prokhor__
but the essence of that vid, imho, is like White_Flame said: the implementor has to deal with the implementation, so the user doesnt have to...
21:58:03
Shark8
prokhor__, Yes, but again with the caveat that you can make things easier on yourself; as I used in the example upthread, you could have gotten an OS to be multi-core by writing the OS using the TASK/TASK TYPE in Ada and recompiling with a multicore aware compiler, exactly by minimizing your dependence on the implementation details (via usage of the TASK/TASK TYPE constructs).
21:59:51
prokhor__
i think there is not one correct answer to that... everybody does as he is used to/suits him best...
22:00:51
Shark8
In some sense it *is* sweeping things under the rug (ie being unconcerned that the TASK *might* be compiled with only a single-core assuming compiler) and putting the onus on the compiler, but on the other hand it's (a) using high-level specification/construction, and (b) allowing the abstraction to be interpreted/realized in some other manner.
22:00:57
prokhor__
i have some vague top-level ideas of my implementations, but i also test them by thinking about specific low-level problems in those cases...
22:03:58
Shark8
prokhor__, (re: Top-down vs Bottom-up) -- I've talked with some programmers who really love Ada because you can do some nice things like Top-down design and bottom-up implementation (in this case by defining the packages, types, and [visible] subprograms [as stubs], getting a clean compile, then "backfilling" by implementing them).
7:28:59
rendar
can we say that apply internally checks the number of arguments that the functions accepts, and if its 2, and the list of params len > 2, it will act like a reduce
7:36:55
wasamasa
you can translate a function accepting several arguments to a function accepting one argument less
7:42:12
wasamasa
if you want to expose apply to the lisp interpreter, it's slightly bit more complicated
7:51:40
rendar
wasamasa, the problem with `return func(*func_args)` is it works when i call (+ 1 2), but it doesn't when i call (+ 1 2 3)
7:52:23
wasamasa
in scheme (+) returns 0, (+ 1) returns 1, (+ 1 2) returns 3 and (+ 1 2 3) returns 6
7:53:27
wasamasa
you need to implement + in terms of functools.reduce, not apply in terms of functools.reduce
7:54:22
wasamasa
no, you need to look at every individual function you need to implement and decide how
7:54:57
rendar
the point is that in lisp every 2-ary functions like +, -, / and so on, seem to take N args
7:55:27
rendar
a kind of minimal lisp just to insert commands in a system, minimal ability to create functions and macros
7:57:51
wasamasa
you still need to decide how basic arithmetic should behave and how a useful standard library looks like
9:17:31
rendar
also, there must be some internal mechanism that will map (- 1) to an unary not function, and (- 1 1) to 2-ary minus function..
9:19:46
wasamasa
but you might as well just have your minus function check for the number of arguments itself
9:27:37
pjb
(defun - (arg &rest args) (if (null args) (* -1 arg) (+ arg (* -1 (apply (function +) args)))))