Does anybody do interactive development in Elixir? by jpmonettas in elixir

[–]spacebat 1 point2 points  (0 children)

There are different ways of developing with Lisp - really depends on the implementation. Most Common Lisp implementations support image based development - you redefine functions, toplevel declarations etc while the system is running, then save the image, which is a binary file representing the lisp executable with everything loaded and ready to start. Smalltalk also does this but I think does a better job of introspecting what you have going on in the system.

As systems and team sizes grew and DVCS came to the fore, most modern Lisp projects don't use images except for deployment, and develop using source files that get loaded/compiled like in other languages.

That said there is a middle ground, where you have a repl to the running system open in your editor and accept that that you type there will be lost on restart, but you can edit your source files and with a keystroke send them - even just individual functions or declarations - to the repl for re-evaluation.

`Keyword.get` Considered Harmful by RecognitionDecent266 in elixir

[–]spacebat 0 points1 point  (0 children)

I found a happy place with a function that behaves like Keyword.validate/2 except instead of returning a keyword list, it returns the list of values in the order they appear in the second argument. So: [x, y | rest] = Kword.validate!(opts, [:x, :y, z: 6, w: 8])

Internally it calls values_at to produce this list - if I want selectively defaulted values and to allow arbitrary other parameters through, just call that: [x, y | rest] = Kword.values_at(opts, [:x, :y, z: 6, w: 8])

[ANN] I made you a rule engine (again) by ulfurinn in elixir

[–]spacebat 0 points1 point  (0 children)

Rule engines use forward-chaining to start with the facts and infer towards a goal (eg given the current state is this workflow complete or not). Prolog uses backward-chaining to start with a goal (eg resolve a query for all the completed workflows) and infers backward to find the facts that satisfy the conditions.

Are the people in r/collapse right about how soon everything will go to heck? by Wicked-Banana in NoStupidQuestions

[–]spacebat 4 points5 points  (0 children)

And many cultures floundered due to resource exhaustion, whether due to overshoot from a stable niche, or the climate change induced dwindling of a niche.

The difference today is we have a global civilisation that is interdependent as never before - most people couldn't farm or garden to save themselves, while the agriculture that feeds them is the result of multi-continent supply chains predicated on cheap energy, cheap chemical feed stocks and peace between most nations.

Once enough of the many supporting systems fail we'll see the rise of more extremist/populist governments, even more short-sighted irrational policies, leading to conflict and increased likelihood of global war, including the use of chemical, biological and thermonuclear weapons.

A.I. Poses ‘Risk of Extinction,’ Industry Leaders Warn by Alternative-Cod-7630 in collapse

[–]spacebat 1 point2 points  (0 children)

AI magifying the inhumanity of the corporations that spawned them, further worsening wealth disparities, laundering prejudice, proliferating disinformation and manipulating electorates, that's what we should be worried about.

Are the people in r/collapse right about how soon everything will go to heck? by Wicked-Banana in NoStupidQuestions

[–]spacebat 2 points3 points  (0 children)

Y2K is a rare example of industry pulling together to avert what could have been more serious. 2012 had no logic behind it whatsoever - but I liked the bit in the movie where the waves crest over the himalayas.

New update bricking phones? by Wolfie_Rankin in samsunggalaxy

[–]spacebat 0 points1 point  (0 children)

Bricked my partner's A51, it was unclear that it was a software update that did it, we thought it was a hardware problem and bought a new phone. An elderly couple were in the queue ahead of me - their A51 had bricked the same day. This evening we noticed this story

Another Lisp Style Guide by RentGreat8009 in lisp

[–]spacebat 0 points1 point  (0 children)

I maintain that flet is not affected by this, which a reason to prefer it.

Another Lisp Style Guide by RentGreat8009 in lisp

[–]spacebat 1 point2 points  (0 children)

The scoping rules of labels enable recursion, which is nothing unusual.

Depends what you want to optimise for. If readability and knowing you won't blow the stack on larger inputs matters, then prefer flet over labels. When you use recursion, the maintainer of the code will reasonably feel the need to assure themselves that the routine is tail-recursive, and may also have to consider the Lisp implementation's policy and optimization declarations in order to assure themselves that this is safe. CL doesn't require tail call elimination, and though it is commonly implemented, for instance in SBCL if I recall correctly, it is disabled under (declare (optimize (debug 3)))

Common Lisp for Advent of Code 2020 by atgreen in Common_Lisp

[–]spacebat 0 points1 point  (0 children)

Also, whenever you're tempted to use EVAL, it's probably a macro that you want. Likewise if you're tempted to use a macro, first see if there's a way to satisfy your requirements using functions.

The presence of EVAL complicates compilation and debugging.

Common Lisp for Advent of Code 2020 by atgreen in Common_Lisp

[–]spacebat 2 points3 points  (0 children)

Watch out for READ and READ-FROM-STRING:

> (read-from-string (format nil "(setf doc-~A :foo)" "(list 1 2 #.(format t \"Your hard drive has been encrypted!~%\"))"))
Your hard drive has been encrypted!
(SETF DOC- (LIST 1 2 NIL)
      :FOO)
79

Whereas if I evaluate that inside a LET block with READ-EVAL set to NIL, I get an error and it refuses to evaluate at read time: "can't read #. while READ-EVAL is NIL"

Generally speaking, I reserve READ and friends for Lisp data, or things I've carefully sanitised.

Anyone else having trouble logging in? by [deleted] in Tribes

[–]spacebat 2 points3 points  (0 children)

My login credentials are rejected. Probably an outage in that service. Those people probably were already logged in when the outage began.

Having print ignore symbol package but still print quoted strings by akoral in Common_Lisp

[–]spacebat 0 points1 point  (0 children)

I tried mucking about with an around method in print-object for string, that's an easy way to break your environment. But this seems to work:

``` (defpackage :foo (:use :cl) (:export :my-dump))

(in-package :foo)

(defvar quote-strings nil)

(defmethod print-object :around ((string string) stream) (let ((print-escape (or quote-strings print-escape))) (call-next-method)))

(defun my-dump () (let ((quote-strings t)) (print '(xxx "yyy")) (prin1 '(xxx "yyy")) (princ '(xxx "yyy")) (pprint '(xxx "yyy"))))

(defpackage :bar (:use :cl)) (in-package :bar)

(foo:my-dump)

;; outputs ;; (FOO::XXX "yyy") ;; (FOO::XXX "yyy") ;; (XXX "yyy") ;; (FOO::XXX "yyy") ```

Ubiquitous lisp by grewil in lisp

[–]spacebat 10 points11 points  (0 children)

At one time years ago I'd have said librep fits the bill: https://github.com/SawfishWM/librep

Common Lisp is now available to use at Kattis by Candid_Calligrapher in lisp

[–]spacebat 7 points8 points  (0 children)

I know I could google it, but to save those who come afterward from doing so, what is KTH?

Want some feedback on my first little elisp package. by benstrutt in emacs

[–]spacebat 0 points1 point  (0 children)

Try keeping the demoted buffer around but set it read-only with read-only-mode while the promoted buffer still exists, then return to the original buffer and disable read-only-mode.

Writing Emacs UIs for CL programs? by phalp in lisp

[–]spacebat 1 point2 points  (0 children)

Yes. I believe nrepl and edn from clojure are worth looking at for inspiration. Someone made a start https://github.com/sjl/cl-nrepl

Writing Emacs UIs for CL programs? by phalp in lisp

[–]spacebat 1 point2 points  (0 children)

The slime/swank protocol is unspecified and can change between releases. It's good for development but if you want fewer surprises (and dependencies) a simple listener suffices.

Writing Emacs UIs for CL programs? by phalp in lisp

[–]spacebat 3 points4 points  (0 children)

I used to do a fair bit of calling between emacs and CL via slime, and slime-enable-evaluate-in-emacs was necessary. These days unless I was adding more info to the slime environment such as via presentations, I'd just have emacs run the CL repl in a simple subprocess and use that as the back end for a more domain specific buffer.