Lisp

53 readers
3 users here now

founded 1 year ago
MODERATORS
51
1
LispE (alien.top)
submitted 1 year ago by Frere_de_la_Quote@alien.top to c/lisp
 
 

I have been working for a few years on my own implementation of Lisp. I have extensively described the language syntax here: https://github.com/naver/lispe/wiki.

The real reason of this version of Lisp is that I wanted to explore array languages such as APL, so I implemented a version of Lisp that is based on arrays and not linked lists. Thanks to this implementation, I was able to implement many operators that are very similar to APL, but which would be implemented on top of a Lisp syntax. However, you can still use traditional Lisp instructions such as car and cdr.

This Lisp also provides many specific types: such as tensors, matrices or dictionaries.

For instance, you can create a tensor in one line of code: (rho 4 5 6 (iota 120)).

I have written a blog on this topic: https://github.com/naver/lispe/wiki/6.20-Conway-Game-of-Life-in-LispE

There are also some implementations for the resolution of Advent of Code enigma in the examples directory. That will give you some flavors of what I try to achieve.

I also provide installers for mac (intel and apple silicon) and windows: https://github.com/naver/lispe/tree/master/binaries. I also compile a version for WebAssembly: See the WASM directory for an example of how to execute LispE in a browser.

For those who are interested, I also implemented my own terminal editor, which is part of the language itself but can also be used independently: jag.

https://github.com/naver/lispe/wiki/1.2-Jag:-Terminal-Editor-With-Mouse-Support-and-Colour-Highlighting

It is implemented as two C++ classes, that can be derived for your own purpose, even though the internal documentation might be a bit lacking.

The whole project is open-source, and was developped from within Naver corporation, however, there are not strings attached.

I have also implemented a mechanism to implement external libraries that can be loaded within the language itself.

52
 
 

------ First, Why i think lisp is awesome -----

Hello, apologies for a clickbait title, I'm a casual programmer, i used emacs lisp about a year or two, i had frustrations with it, i had fun with it to the point where I'd rather configure emacs that play any video game, and i decided to try common lisp and i realized that i actually feel more comfortable programming in lisp than i do in python.

By "more comfortable" i mean i find it easier to translate my thoughts into code in lisp rather than python, because:

  1. of a fact that i can modify a state of a program while a program is running with is REALLY underappreciated feature btw, that means my thoughts are already in-sync with a program state, and i don't have to rethink how program will execute from start to finish. ~~(if non-lisp languages also did that i would be really happy, but for some reason only lisp does that as far as i know)~~

  2. its just a simple syntax. i find it harder to remember syntax sugar than i do keywords. also keywords are easy to auto-complete with a code editor.

  3. interactive repl. combine `point 1` with the fact that the code in your editor buffer and your repl is also synced in with the program state, its just really intuitive, it feels like its always supposed to be this way

------ now going back to a point of a post -------

Hearing about a history of lisp you heard the words like "pioneer of..." "used to be..." "inspired this-and-that-modern-programming-language.exe" gave me an impression like they are talking that lisp is antiquated language. All of a IT fields that lisp was a captain of, for example, AI development, is now lead by python. the community is comparatively small. i can tell that by glancing at subreddit numbers, its not looking that hot:
r/lisp 38k / 71 online
r/Common_Lisp 6.9k / 13 online
r/rust 256k / 865 online
r/C_Programming 147k / 137 online
r/Python 1.2m / 761 online
r/java 307k / 150 online
...
Technically speaking i can still find all the libraries and compilers i need, and free educational material is also good. But i think not having enough people, means less people that talk about it, means diminishing return on people interested in a subject, means it can hit a point of no return where it is too little people to make any practical use of lisp, because not enough manpower to maintain it, and no job opportunity. Idk this last part might be a delusional thinking, but this is genuinely what i think could happen. I think people need to talk more about lisp, if I'm correct of my assumption. Peace!

53
 
 

There are many Lisp languages like Common Lisp, Scheme, Clojure, etc., and they're quite different to each other. For examples, one needs main as the entry point, another has while loops, some use t and nil while others use #t and #f, one has its codes starting with #lang, and so on. My question is, which language in the Lisp family is the most similar to the original LISP, be it in syntax, features, or appearances?

54
55
 
 

I have quite a lot of code that I have used for commercial web projects over the years. Mainly in my marketing agency (which was powered by common lisp). Some of this code might be useful to the wider community.

First one here: https://github.com/vinn2010/cl-stackexchange

If it's useful, give it a star (because my goal in life is to collect internet points that can be used to buy absolutely nothing).

56
 
 

I have conducted my own analysis and computational experiments regarding Gödel's incompleteness theorems in the style of Chaitin's Lisp. Is my approach correct? I am eagerly awaiting advice from those with expertise in this matter. Gödel’s Proof in Lisp. A Complex Book | by Kenichi Sasagawa | Nov, 2023 | Medium

57
 
 

Hey, i need to enhance my workflow within AutoCAD. I frequently encounter situations where I need to copy an object and paste it in various points across my drawing, there are instances where i need to align the object with the wall or where i want to put it, this process involves multiple steps, copying, pasting, and manually rotating the object for each occurrence. Is there an AutoLISP or command that facilitates the rotation of the object while I'm positioning it to the desired point ?

58
 
 

“When you realize you have enough, you are truly rich.” - Laozi

59
 
 

Hello everyone,

I wanted to share a comprehensive cloud-init YAML file that I've put together for setting up a robust server environment. It's tailored towards creating a secure, user-friendly, and developer-ready setup right from the get-go. Here's a glimpse of what it covers:

  1. Locale, Keyboard, and Timezone Configuration: Sets up the basic locale, keyboard layout, and timezone for the system.
  2. User and Group Management: Creates system and regular users, assigns them to groups, and sets up sudo and SSH key authentication.
  3. Package Management: Installs a range of essential and useful packages, including fail2ban, ufw, nginx, certbot, sbcl, emacs, git, and many more. It also handles automatic package updates and upgrades.
  4. Security Enhancements: Configures SSH, ufw firewall, and fail2ban for better security.
  5. Nginx Setup: Sets up Nginx with a reverse proxy and SSL using Certbot.
  6. Git, SBCL, SLIME, and Quicklisp Setup for User: Sets up a ready-to-code Lisp environment for the user.

I believe this setup can save a lot of time and ensure a solid foundation for anyone looking to deploy applications or development environments on cloud instances. It's especially geared towards those who prefer a Lisp-friendly environment.

https://git.sr.ht/~marcuskammer/cloudinit/tree/main/item/sbcl-nginx.yml

Feel free to use, modify, or suggest improvements to this setup. I'm open to feedback and would love to hear your thoughts or experiences with similar setups. Let's make server setup a breeze!

60
 
 

Hello guys,

I have a question regarding the nested backquotes in macros. I wrote a macro, which creates lexical bindings for "port:ip" values:

(defun mkstr (&rest args)
  (with-output-to-string (s)
    (dolist (a args) (princ a s))))

(defun mksymb (&rest args)
  (values (intern (string-upcase (apply #'mkstr args)))))

;; my macro
(defmacro with-free-ports (start end &body body)
  (let ((range (loop for port from start to end collect (format NIL "127.0.0.1:~a" port)))
	(n 0))
    `(let ,(mapcar #'(lambda (p) `(,(mksymb "PORT-" (incf n)) ,p)) range)
       (progn ,@body))))

One sets a range of ports on localhost and these ports are bound to symbols port-1, port-2, etc..

(with-free-ports 1 3 port-1) ;; => "127.0.0.1:1"

This works fine if the start or end parameters are given as values. But if they are variables. which must be evaluated, this macro doesn't work:

(let ((start 1))
  (with-free-ports start 3 port-1)) ;; error

In order to fix it, I made the let- bindings a part of the macro-expansion:

(defmacro with-free-ports (start end &body body)
  `(let ((range (loop for port from ,start to ,end collect (format NIL "127.0.0.1:~a" port)))
	(n 0))
     `(let ,(mapcar #'(lambda (p) `(,(mksymb "PORT-" (incf n)) ,p)) range)
	       (progn ,@body))))

but get a compilation warning that the body is never used. I assume this is because of the inner backquote.

To evaluate ,@body inside the inner backquote, I use one more comma, and the macro compiles without warnings:

(defmacro with-free-ports (start end &body body)
  `(let ((range (loop for port from ,start to ,end collect (format NIL "127.0.0.1:~a" port)))
	(n 0))
     `(let ,(mapcar #'(lambda (p) `(,(mksymb "PORT-" (incf n)) ,p)) range)
	       (progn ,,@body)))) ;; one more comma here

But it doesn't work:

(let ((start 1))
  (with-free-ports start 3 port-1)) ;; error: port-1 is unbound

because with this ,,@body I evaluate port-1: (progn ,port-1) and this triggers the error.

I would appreciate if smbd can help me a bit and say what I am doing wrong.

Thank you.

61
 
 

I decided to release my book early, in honor of RacketCon that starts tomorrow morning!

I cover using Racket Scheme for implementing many short AI examples including LLMs (OpenAI, Anthropic, Mistral, and Local Hugging Face), vector datastore, NLP, semantic web, Knowledge Graphs, and non-AI utilities.

I am about 60% done with this “live book” (there will never be a second edition: as I add material and make corrections, I simply update the book and the free to read online copy and all eBook formats for purchase get updated).

You can read my live eBook online for free using the link: https://leanpub.com/racket-ai/read

62
63
 
 

So I was working on and off on this project for the last months. I use it now in production on a Raspberry Pi, so I thought I could announce its existence.

There are a lot of rough edges but useable. Maybe interesting for you.

https://github.com/mdbergmann/cl-hab

64
65
 
 

I may have found a solution to my desire for C-c C-z in the slime repl (default slime-nop) to return you to the buffer that sent you to the repl via slime-switch-to-output-buffer (also C-c C-z), with regard to a post/request I made a year ago:

https://www.reddit.com/r/Common_Lisp/comments/xa7imh/seeking_reverse_of_slimeswitchtooutputbuffer/?utm_source=share&utm_medium=web2x&context=3

Basically calling a function which does (switch-to-buffer (slime-recently-visited-buffer 'lisp-mode)) works, or at least does something interesting by approximation.

I'm not much of an emacs coder though and I'm at a loss though as to how to bind my new function calling the above switch-to-buffer to C-c C-z only in the slime repl buffer. Any tips?

66
 
 

During "Metal Tornado", timestamp 12:28 on the following URL: https://www.youtube.com/watch?v=dQ-knIeSkPc

Looks like an XML parser, perhaps Emacs Lisp? Wonder why they chose that code.

So if you misconfigure Emacs, does it create a magnetic tornado spewing destruction across nearby cities? ;)

67
 
 

I am trying to write a Babashka script that downloads some files from a remote host using an SSH connection. For this, I use the 'epiccastle.bbsh' pod. The problem is that the script does not terminate, it gets stuck at the end of the main thread process. I thought it might be due to the thread pool used by Clojure agents and added the call to '(shutdown-agents)'. However, the script still gets stuck.

My babashka version is 'v1.3.185'.

I have created a minimal version that reproduces the error:

(ns sample
  (:require [babashka.pods :as pods]))

(def bbsh-pod (pods/load-pod 'epiccastle/bbssh "0.5.0"))
(require '[pod.epiccastle.bbssh.core :as ssh])
(require '[pod.epiccastle.bbssh.scp :as scp])

(def user "user")
(def cert "/home/user/.ssh/id_rsa")

;; Main process
(let [session (ssh/ssh "localhost" {:username user :identity cert})
      opts {:session session}]
  (scp/scp-from "/etc/hosts" "remote-hosts" opts)
  (shutdown-agents)
  (println "shutdown"))

The script actually downloads the file, but does not terminate. Am I forgetting something? Is it a problem in Babashka? Could the problem be coming from the pod?

Asciinema Cast: https://asciinema.org/a/Loa2w96lXCzPE6LHtz4N4KGsm

Note: for the asciicast I added a '(System/exit 1)' at the script end and it stills gets stuck.

68
 
 

OK, so I'm teaching a class in LLMs and want to use copilot for the next batch of students, who are from the IT department. If I want to demonstrate copilot and copilot chat, I need to use something other than emacs because the only emacs based interface to copilot doesn't have chat and appears somewhat fragile.

Copilot supports Visual Studio, Visual Studio Code, or one of the JetBrains IDEs.

Since this is a long-term assignment, paid for commercial offerings are fine (i.e. JetBrains). It seems VS Code has a few options, like Common Lisp vs code extension or Alive. The former seems to be a syntax highlighter. Alive looks like it has a REPL and may be closer to a real development environment.

Anyone got a favorite combination? Also open to other co-pilot / Common Lisp integrations that I may have missed.

69
70
71
72
73
 
 

Hi all

I have this code

{:path ["src"]
 :deps {org.clojure/clojure {:mvn/version "1.11.1"}
        org.clojure/java.jdbc {:mvn/version "0.7.12"}
        mysql/mysql-connector-java {:mvn/version "8.0.30"}}}

Import changes work.

But if I try to change the mysql-connector-java to any versions higher than 8.0.30, it will throw an error.

{:path ["src"]
 :deps {org.clojure/clojure {:mvn/version "1.11.1"}
        org.clojure/java.jdbc {:mvn/version "0.7.12"}
        mysql/mysql-connector-java {:mvn/version "8.0.33"}}}

The error - Could not find artifact mysql:mysql-connector-java:jar:8.0.33 in central (https://repo1.maven.org/maven2/)

If I use the version 8.0.30, it's released on 25th July, 2022.

Does this mean I can't use latest libraries from maven?

74
75
 
 

Racket is now on Instagram at <https://www.instagram.com/racketlang/>

Racket has a presence on many social media platforms due to the diversity of the people who use Racket. Look here to find one that suits you: https://racket.discourse.group/t/racket-on-social-media-help-others-find-out-about-racket/1927

view more: ‹ prev next ›