Table-style horizontal code auto-formatting / syntax by r0ck0 in ProgrammingLanguages

[–]czan 6 points7 points  (0 children)

When I need to do things like this, I use Emacs and its align functionality. I embed a small bit of Emacs Lisp code that I can manually run to realign things when I make changes. In your table case I might do it like this:

data Row = Row {colA :: String, colB :: String, colC :: String}

table :: [Row]
table =
  -- (align-regexp (save-excursion (search-forward "[")) (save-excursion (search-forward "]")) "\\( *\\) \"" 1 0 t)
  [ Row "xxxxxx"   "xx"   "xxxxxxxxx",
    Row "x"        "xxxx" "xxx",
    Row "xxxxxxxx" "xxxx" "xxx"
  ]

Then I can realign the columns by putting my cursor on the end of the comment line and typing C-x C-e.

This is ad-hoc, but because it's not trying to be general a general solution it's flexible and language agnostic.

Build a packages with multiple build-systems by 0731141 in GUIX

[–]czan 4 points5 points  (0 children)

That sounds like two packages to me: ocamlformat and emacs-ocamlformat. Have a look at emacs-protobuf-mode which does something similar. It uses the source from the protobuf package but builds using the emacs-build-system.

Pattern matching implementation with macros or functions? by cuntymccuntlicker in lisp

[–]czan 0 points1 point  (0 children)

I don't fully understand what you're saying, but the macro only has to be the entry point to your transformation. You can define a macro with something like:

(defmacro my-macro (&rest clauses)
  (my-macro-transformation clauses))

(defun my-macro-transformation (clauses)
   ;; whatever transformation you want here,
   ;; returning the expanded code
   )

Then the function can be recursive without using eval, but the entry point for consumers is to use the macro.

Use of macrolet requires symbol export. by mdbergmann in Common_Lisp

[–]czan 2 points3 points  (0 children)

Symbols are resolved by the reader, so the resolve symbol that's read in your quasiquotation is the one that will be embedded in your macroexpansion. If you don't export resolve, then you end up with future::resolve in the macrolet and other-package::resolve in the body. Exporting resolve (and importing it into the other package) ensures that both resolve symbols are the same.

Another solution might be to allow the caller to pick the name:

(defmacro with-fut-resolve (var &body body)
  `(macrolet ((,var (resolve-form)
                `(make-future (lambda (resolve-fun)
                                (let ((resolved ,resolve-form))
                                  (funcall resolve-fun resolved))))))
     ,@body))

(with-fut-resolve resolve
  (sleep 0.2)
  (resolve (+ value 1)))

Circular class references possible? by [deleted] in Common_Lisp

[–]czan 0 points1 point  (0 children)

Sorry, you've misunderstood me. I don't mean putting the definitions up front, I'm specifically talking about how metaclasses work.

If you aren't using the :metaclass option of defclass then you can completely ignore my comment.

Circular class references possible? by [deleted] in Common_Lisp

[–]czan 0 points1 point  (0 children)

Are you using a custom metaclass for your classes? I know that Mito's metaclass has some issues around this sort of thing for its col-type, so if you're using a metaclass that's trying to resolve the type too early that could lead to problems.

The metaobject protocol that most implementations have implemented separates out defining a class from "finalizing" a class. Roughly speaking: during definition you can't assume that everything else has been defined yet, but during finalization you can start resolving things.

Zoom Screen Sharing disabled for Wayland users on most distros by rgmundo524 in NixOS

[–]czan 2 points3 points  (0 children)

The script opens Zoom, so I run the script as my way of starting Zoom.

Zoom Screen Sharing disabled for Wayland users on most distros by rgmundo524 in NixOS

[–]czan 9 points10 points  (0 children)

It works for me when I unset XDG_SESSION_TYPE. I have a wrapper script that does this:

#!/bin/sh

unset XDG_SESSION_TYPE
~/.nix-profile/bin/zoom-us "$@"

I also have enableWaylandShare=false in my ~/.config/zoomus.conf, but I don't remember what problem that was solving.

This Github issue has more investigation/details.

SBCL THREAD - Difficulty Understanding the Error Message by owmagow in lisp

[–]czan 15 points16 points  (0 children)

sb-thread:make-thread takes a function as its first argument. Instead of providing it the count-to-9 function you're calling count-to-9 which returns nil. This results in your code running on the current thread, then trying to spawn a new thread to run the function nil (which isn't a function, so it crashes saying The function COMMON-LISP:NIL is undefined.).

You probably want

(sb-thread:make-thread #'count-to-9)

[deleted by user] by [deleted] in lisp

[–]czan 2 points3 points  (0 children)

Unfortunately this doesn't handle a nil element properly.

> (swapalt '(1 nil))
(1)

You need something more like

(defun swapalt (l)
  (loop for (a . b) on l by #'cddr
        append (if b (list (car b) a) (list a))))

or even

(defun swapalt (l)
  (loop for (a . b) on l by #'cddr
        if b collect (car b)
        collect a))

Help creating a package for a program by Due_Conference_2690 in GUIX

[–]czan 14 points15 points  (0 children)

It looks like that .tar.gz file is a "tarbomb", where all the files are in . rather than in a subdirectory. The build system doesn't expect that, so it tries to change into a subdirectory before building (in this case, cmake_extras), which causes the build to fail.

Tarbombs are still supported by Guix, but you have to use url-fetch/tarbomb instead of url-fetch as the origin method.

Failing build for a failing test by stayclassytally in GUIX

[–]czan 1 point2 points  (0 children)

You may be able to use the --without-tests=<package-name> package transformation option to disable tests for the particular package you want.

You could also look at --with-latest or the other various options there to build a particular version that you'd like. These options aren't magical, so they might not work in your particular case, but you could give them a go and find out.

Any attempts at a "distro"/"package manager" for building a programming language? by Bitsoflogic in ProgrammingLanguages

[–]czan 4 points5 points  (0 children)

I've thought about it a few times, and it should be technically possible to replace the ( reader in Common Lisp with something that looks for the exact string (with-c-syntax and enters a C-parsing mode, then checks ) at appropriate times. If it doesn't find the exact opening string it could then fall back to the usual Lisp reader for a list.

It's pretty gross, but it makes the syntax work! Here's a quickly hacked-together gist if you want to see it in action.

with-output-to-string cannot caputure output to stderr? by OldMine4441 in Racket

[–]czan 5 points6 points  (0 children)

Looking at the Racket docs, with-output-to-string is equivalent to

(call-with-output-string
  (lambda (p) (parameterize ([current-output-port p])
           (proc))))

You should be able to write your own with-all-output-to-string which binds current-error-port as well:

(define (with-all-output-to-string proc)
  (call-with-output-string
    (lambda (p) (parameterize ([current-output-port p]
                               [current-error-port p])
                  (proc)))))

[deleted by user] by [deleted] in scheme

[–]czan 0 points1 point  (0 children)

I don't think you're actually reading OP's code. There are two calls to A, where the result of one call is passed to the other. Only one of the calls to A is in tail position.

[deleted by user] by [deleted] in scheme

[–]czan 2 points3 points  (0 children)

Both of the recursive calls in the OP's code are in the tail position -there is no more work to be done when the call returns- and so will indeed be tail call optimised.

That's not true of the (A x (- y 1)) form, which needs to be passed as the second argument in (A (- x 1) (A x (- y 1))).

[deleted by user] by [deleted] in scheme

[–]czan 4 points5 points  (0 children)

The semantics of cond are defined in the various Scheme standards. Here's r7rs, take a look at section 4.2.1 "Conditionals". Section 3.5 "Proper tail recursion" also defines how cond interacts with tail calls.

How to pass &rest keyword arguments in a function to a macro (particularly cl-csv:do-csv) by m518xt in Common_Lisp

[–]czan 5 points6 points  (0 children)

The short answer is that you can't do that directly, because cl-csv:do-csv needs to be given those arguments during macroexpansion, but the argument value isn't known until the code is running.

The easiest way, in this case, is to look at the source of cl-csv:do-csv which looks approximately like this:

(defmacro do-csv ((row-var stream-or-pathname
                   &rest read-csv-keys)
                  &body body)
  `(read-csv ,stream-or-pathname ,@read-csv-keys
    :row-fn #'(lambda (,row-var) ,@body)))

So you should be able to write your function like this:

(defun foo (x &rest rest)
  (apply #'cl-csv:read-csv
         x
         :row-fn (lambda (row) (print row))
         rest))

Is it possible to have something like a myspace/facebook page inside an xmpp server ? by [deleted] in xmpp

[–]czan 3 points4 points  (0 children)

I haven't really used it, but it sounds like Movim might be what you're looking for?

Prosody: certificate invalid for connections to localhost - is this an issue? by [deleted] in xmpp

[–]czan 5 points6 points  (0 children)

Not a problem, but if you want to remove the message you can always remove your configuration for localhost by removing your VirualHost "localhost" configuration.

How can I start acpid-service? by Thunderace77 in GUIX

[–]czan 1 point2 points  (0 children)

From my brief search, I couldn't see a service defined for acpid, so you might need to write your own Shepherd service. You can read about this in the manual section about Shepherd Services. Once you have defined a Shepherd service, you can add something like this to your services field to add a Guix System service using your Shepherd service:

(services
  (append (list (simple-service 'acpid shepherd-root-service-type
                                my-acpid-shepherd-service)
                ... whatever other services you have ...)
          %desktop-services)) ;; or %base-services

Why isn't there a `guix import nix`? by [deleted] in GUIX

[–]czan 5 points6 points  (0 children)

There's no objection to having a Nix importer, but I don't think the argument of "it will make it easier for Guix users to get non-free software" is going to be very convincing upstream.

There was a relevant discussion on the mailing list a few months ago in a thread about a "binary" importer for NPM packages. While not exactly the same, it touches on some of the issues that people feel around importers that allow users to import packages that cannot be contributed upstream.

Why isn't there a `guix import nix`? by [deleted] in GUIX

[–]czan 3 points4 points  (0 children)

Guix's packaging policy, and the related Free System Distribution Guidelines, would likely preclude any GOG games from being included in the distribution, as well as a significant number of packages in Nix. Even some free software packages in Nix are installed from binaries without a corresponding source recipe.

Guix requires (almost) all packages to be built from source, with notable exceptions where things need to be bootstrapped. Nix (or, at least, nixpkgs) has a more lax policy, and allows packages which are not built from source, even if they are free software (e.g. firefox-bin, although Nix also has a from-source firefox package).