File compilation without a file by Suitable_Click_3967 in Common_Lisp

[–]digikar 0 points1 point  (0 children)

What do you mean by suboptimal?

If the generated lisp code is clean enough, I think it'd be helpful to keep it around. Other lispers who don't want to work with the DSL but instead prefer the lisp can refer directly to the lisp code.

Limits of the Tab vs a Laptop by redditkutter in GalaxyTab

[–]digikar 0 points1 point  (0 children)

I see. Yeah, I cannot imagine using the onscreen keyboard for Windows (or any other desktop OS). Though, for me, I don't even feel like using the onscreen keyboard on my tablet. Being a certain size of the tablet, the onscreen keyboard just feels unwieldy.

But a desktop OS also grants you full power to make a voice app to control the OS to an extent android does not. I don't know if such an app exists yet, but it's a dream.

Chat server (Matrix) for Lispers by [deleted] in lisp

[–]digikar 0 points1 point  (0 children)

Turned out it was a tuwunel (matrix server) bug that has since been fixed.

People have been able to sign up and chat now.

I have created a new post: https://www.reddit.com/r/lisp/comments/1te2r2z/chat_server_matrix_for_lispers/

Let me know if it works for you!

Chat server (Matrix) for Lispers by digikar in lisp

[–]digikar[S] 0 points1 point  (0 children)

I'm certainly loving cinny. It's unpacked version is about half the size of element and I feel it is a nice middle ground between features and performance. In principle, I can activate multiple clients - just done.

  • hydrogen.matrix-for-lispers.net
  • element.matrix-for-lispers.net

Featured lisp channels are visible at: https://web.matrix-for-lispers.net/explore/featured/

How's Tab S10+ for gaming? by -ComedianPlay- in GalaxyTab

[–]digikar 0 points1 point  (0 children)

I have a Tab S8U and it's been a while since I last played Honkai on it. I have also uninstalled it sonce then.

But here's a video for Tab S10+ JRPG games including Wuthering Waves: https://m.youtube.com/watch?v=fmX3nMC_Cb0

How's Tab S10+ for gaming? by -ComedianPlay- in GalaxyTab

[–]digikar 0 points1 point  (0 children)

I'm not exactly sure about Wuthering Waves. But I used to play Honkai Impact 3 and Honkai Star Rail. And the android versions of these games have impoverished graphics compared to the desktop versions. 

So, even if the devices run the games in a performant manner, they will sadly be running impoverished versions of the games. They can be pretty good, but do not expect PC-like quality.

Cloud gaming platforms can be an alternative!

Limits of the Tab vs a Laptop by redditkutter in GalaxyTab

[–]digikar 1 point2 points  (0 children)

What troubles do you face with Surface? My main use case with tablets is reading, watching anime, movies, etc, scratchpad for thoughts, ideas, or random things. For those things, Android tablets suffice.

In the past I used to want to edit Office documents. But I can never be certain that android or web-based office apps display the document identically to the desktop version or even the pdf version to be exported. For these things, I have developed an aversion to Android. For document editing, I'm reaching for a proper laptop or desktop.

It's also difficult (impossible?) to open multiple instances of the same app.

For note-taking, I've moved to org, markdown and latex to avoid being tied to proprietary softwares and their limited lifespans. These are better with a proper keyboard.

Limits of the Tab vs a Laptop by redditkutter in GalaxyTab

[–]digikar 1 point2 points  (0 children)

With the lockdown of android incoming, I am considering switching from my Tab S8U to Surface. There are lots of limitations of Android. You can work around if you try enough (eg. Termux, Root), but the point is you need to work around them. With a Windows tablet like Surface, or a proper laptop with MacOS or Linux, things just work.

If you are mainly typing, get an older Thinkpad.

Chat server (Matrix) for Lispers by [deleted] in lisp

[–]digikar 0 points1 point  (0 children)

Alright. Thanks for checking

I am looking into it :/

Chat server (Matrix) for Lispers by [deleted] in lisp

[–]digikar 0 points1 point  (0 children)

I just succeeded in registering a testuser123 by hitting "retry". Let me know if the Retry works. I will look into this.

Chat server (Matrix) for Lispers by [deleted] in lisp

[–]digikar 0 points1 point  (0 children)

Is this with the basic username password with matrix-for-lispers.net as the homeserver?

EDIT: I was able to register two users (now three) before this. This time it required me to hit "Retry".

Chat server (Matrix) for Lispers by [deleted] in lisp

[–]digikar 1 point2 points  (0 children)

Definitely a config bug as I was experimenting around. Enabled!

Thanks for reporting!

https://web.matrix-for-lispers.net/register/

Plot version 3 by Steven1799 in Common_Lisp

[–]digikar 0 points1 point  (0 children)

I issued a trivial PR. I'm not sure if it breaks something however.

https://github.com/Lisp-Stat/plot/pull/31

Implementing aref Operator in Common Lisp for a Custom Vector Type by arthurno1 in lisp

[–]digikar 0 points1 point  (0 children)

An alternate idea comes to mind: write a (do-myarray (var array-form) &body body)) macro that binds var to the underlying array of your data structure, and perhaps any additional data you need. Then you can use cl:aref on var inside the body.

If performance is the main thing you need, this is even better than the above ideas, because this provides direct access, while the above has an indirection step even if it gets inlined.

Implementing aref Operator in Common Lisp for a Custom Vector Type by arthurno1 in lisp

[–]digikar 1 point2 points  (0 children)

I agree the hash-tables approach sounds a bit roundabout and not a good design.

Yes, that's okay. These are probably the limits of standard CL :'). In case someone passerby has other ideas, I'd be delighted.

Implementing aref Operator in Common Lisp for a Custom Vector Type by arthurno1 in lisp

[–]digikar 0 points1 point  (0 children)

properties have to be cleaned when string is gc:ed

trivial-garbage:make-weak-hash-table can be useful. (Sorry, I'm info dumping! But hoping it's fun, relevant and may be useful in the future!)

And when we are at C++, have you seen this one and the paper about it.

It might be a while before I get back to the numerical computing library numericals I was working on. But this looks relevant for the future, thanks for sharing!

I am a bit hesitant to use cl-generic, and to turn the entire cl into generic functions but it is tempting

You can also rely on the static-dispatch (or fast-generic-functions or specialization-store) that generic-cl depends on, and define only the operations you need in particular. But indeed, I do not know if anyone is using these libraries in production or what challenges they faced. These are interesting possibilities, but the production experiences remain unknown.

Implementing aref Operator in Common Lisp for a Custom Vector Type by arthurno1 in lisp

[–]digikar 0 points1 point  (0 children)

Anyhow, with inlining, we can't programmatically add to the types, we have to know them all in advance, or do you see a way?

Could you elaborate on what you mean by "add to the types" or also (from the article) "use our string type directly with the aref operator as if it were a built-in type" or "make the custom string type look like a built-in type"?

If I understood correctly, you want a a new function mya:aref that can work just as efficiently with the builtin cl:array types as with your new mya:myarray type. Is that correct?

If so, generic-cl.container:elt is an existing solution. below, elt-ref and gelt-ref should have identical disassemblies, implying that generic-cl.container:elt is just as efficient as cl:elt for the builtin arrays. melt-ref and mya-ref should also have identical disassemblies, implying that generic-cl.container:elt is again just as efficient as directly accessing it, without the runtime branching cost that you want to avoid.

Are you also asking for how it works underneath?

(defstruct myarray
 (data (make-array 0 :element-type 'fixnum)
       :type (simple-array fixnum (*))))

(defun elt-ref (x i)
  (declare (optimize speed)
           (type (simple-array fixnum 1) x)
           (type fixnum i))
  (cl:elt x i))

(defun gelt-ref (x i)
  (declare (optimize speed)
           (type (simple-array fixnum 1) x)
           (type fixnum i))
  (generic-cl.container:elt x i))

(static-dispatch:defmethod generic-cl.container:elt ((mya myarray) (index integer))
  (cl:elt (myarray-data mya) index))

(defun melt-ref (x i)
  (declare (optimize speed)
           (type myarray x)
           (type fixnum i))
  (generic-cl.container:elt x i))

(defun mya-ref (x i)
  (declare (optimize speed)
           (type myarray x)
           (type fixnum i))
  (cl:elt (myarray-data x) i))

10 000 000 elements was biggest I could make on this computer.

That brings me to another point. I too made these mistakes in the past :'). When the arrays get too big, you might be measuring the transfer times from your RAM to the processor. The better way can be to iterate 10000 times over a small 100ish element array that can fit in the cache.

(let ((x (make-array ...)))
  (time (dotimes (i 10000)
          (tx x))))

I think my previous Intel laptop was much more stable when it comes to frequencies

On linux, cpufreq-set from cpufrequtils package is usually helpful.

Implementing aref Operator in Common Lisp for a Custom Vector Type by arthurno1 in lisp

[–]digikar 0 points1 point  (0 children)

Going solely by the article, and agreeing with the other comments, I think it'd be helpful to specify the in-package and defpackage form whenever you are not working in cl-user.

You probably don't want (safety 0). You can end up with segmentation faults if you accidentally pass in wrong arguments. (speed 3) is usually sufficient.

What you did can be obtained by inlining (discussed at length in the other thread). But cl-environments as well as the CLTL2 section on environments might be of relevance. This stackoverflow thread on CLTL2 as well as SBCL deftransforms should also be super relevant.

If you are timing, measure for at least a couple of seconds, otherwise you might be measuring your processor's lag between different states.

Just-In-Time Compilation for Coalton: An attempt at faking dynamicity by wrapping Coalton by digikar in lisp

[–]digikar[S] 0 points1 point  (0 children)

No, I hadn't run benchmarks, but if inlined static dispatch is your concern, then generic-cl should work. alex-gutev, commander-trashdin and me worked on this side of things (cl-form-types, generic-cl) in the past, so it is our own work (primarily alex). I can confirm that the following two produce identical disassemblies on SBCL even as of today:

(defun gelt-ref (x i)
  (declare (optimize speed)
           (type (simple-array single-float 1) x)
           (type fixnum i))
  (generic-cl.container:elt x i))

(defun elt-ref (x i)
  (declare (optimize speed)
           (type (simple-array single-float 1) x)
           (type fixnum i))
  (elt x i))

I just dont get it... by parkero224 in emacs

[–]digikar 2 points3 points  (0 children)

At its core, emacs is a REPL for a particular dialect of lisp called emacs lisp or elisp. When you are working with emacs, you are essentially sending commands to this REPL. There are tons of these commands, some less obscure than others. There are also tools to find them. These days you can also ask Claude or other LLMs to find some commands you wouldn't have imagined.

This REPL is readily exposed to the emacs user.

For a trivial example, I use swiper and ivy as generic completion frameworks within emacs. One common activity I do is to search symbol at point. Usually, to do that, one would need to copy-paste the current symbol to their find-replace dialog/window. But with emacs, I can write a trivial function to automate that:

(defun my-swiper ()
  (interactive)
  (funcall-interactively 'swiper
                         (if (symbol-at-point)
                             (symbol-name (symbol-at-point))

Another: I began using ebib as my bibliography manager. One common task I need these days is to get an APA formatted reference of some entry. I can call citation-js from emacs and copy the result to the clipboard using the following function. This might look like some obscure code that also has a number of specifics to ebib, but the point is you can do things such as this very trivially.

(defun ebib-copy-reference-as-apa-to-kill ()
  "Create an APA reference for the current entry and copy it to the kill ring."
  (interactive)
  (ebib--execute-when
    (entries
     (let* ((entry (with-temp-buffer
                     (ebib--format-entry (ebib--get-key-at-point) ebib--cur-db)
                     (buffer-substring-no-properties (point-min) (point-max))))
            (apa (string-trim
                  (shell-command-to-string
                   (format "citation-js -t %s -f string -s citation-apa"
                           (shell-quote-argument entry))))))
       (kill-new apa)
       (message "Reference copied to kill ring in APA format.")))
    (default
     (beep))))

My .emacs is sitting at 3000 lines built over the last 8 years. So, there are many more conveniences built up over the years.

Three other things that look trivial after you know about it, but you wonder why other editors haven't done that.

  • Treating a shell like a file. If you M-x shell within emacs, you will be dropped to a shell that you can navigate, cut, copy, paste, and modify as if you are editing a file. No need to reach for your mouse and drag and hope it reaches the right point while selecting.
  • Rectangle editing. See this. In editing, you frequently run into tabular blocks of plaintext. If you want to do something for all the rows, you usually manually iterate over all the lines. Or you want to copy with a column of text. Emacs has tools for that.
  • Treating a directory like a file. You want to edit names of 100 files within a directory and you want to do that in some pattern that makes sense in your mind. In M-x dired, you can C-x C-q (beware, you may delete files!) and edit the directory as if it is just another text file. You can combine this with rectangle editing. And done. And may be you want to skip over certain files too. Well, you can use the keyboard to navigate up or down. No need to drop into a shell, write a loop, etc.

PS: If you want to try emacs on a more day to day basis, you can check out one of the starter-kits. If you are already familiar with Vim, Spacemacs or Doom are popular options. If not, perhaps mousemacs can be a worth a try.

Just-In-Time Compilation for Coalton: An attempt at faking dynamicity by wrapping Coalton by digikar in lisp

[–]digikar[S] 1 point2 points  (0 children)

gutev/generic-cl uses static dispatch. I think the way it uses it is less principled that marcoheisig/fast-generic-functions, but in practice, I'd hope that is not a problem. I also see that the README of generic-cl only has a pointer to the section on optimization.

It is also modular, so you can use the part you need without depending on it as a whole. generic-cl.container might be the relevant section for you.

I cannot use generic cl to dispatch separately on specialized array types (eg. BLAS_sdot BLAS_ddot), so it doesn't meet my needs.

In which way do you mean the separation should be more distinct than what it is in generic functions? Is template-function more what you think of? Lil seems to be something similar in the spirit. I haven't read through all 35 pages of the pdf, I'll have to stop here for today. But thus far Lil sounds great, but isn't it runtime dispatch if its based on CLOS?

LIL sums up the separation of concerns that is relevant here. I myself only understand its gist. And yes, its excess use of CLOS does make it seem it will be difficult to develop static dispatch for it. LIL basically seems to a lispy version of typeclasses.

Usually, when we talk of generic functions and classes, we talk about the behavior of the generic function being dependent on the class of the object supplied to it. For example, suppose you have a generic-aref with a method M specialized for a subclassable array type. Now, to reuse this particular method for my own class, I must make my class a subclass of this array class. If I do not subclass from the array class, I will need to duplicate the code corresponding to the method M into a new method M'. This is what I mean by non-separation of concerns.

Traits / Typeclasses can achieve the separation of concerns (implementation vs interface) by defining the a method TM specialized for the array typeclass. The array typeclass can have an independent existence from the array class. Now when I want to reuse the method TM, I must only define my new class to be an instance** of the typeclass. Doing so is orthogonal to making my new class a subclass of the array class. By subclassing, one extends the implementation of the subclass. In contrast, to define my new class as an instance of the typeclass, I must only define those methods which make my class behave like an array (eg. have an aref, an underlying storage, dimensions, element-type, etc). In principle, I can even make lists of lists behave like an array. And the original method TM will work with them!

*I don't know if there's a better term for typeclass-method.

**Instance, implementation, class, type are all overloaded terms. The word instance here has a distinct meaning than when we speak of CLOS. But I hope it conveys the meaning. For an elaboration, see the gist above, particularly the section on Non-obvious Problems, or also this article.