all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: <emacs-devel@gnu.org>
Subject: Improve the byte compiler: cryptic error message,  macros
Date: Tue, 30 Jul 2024 17:16:13 +0200	[thread overview]
Message-ID: <87msly7vwi.fsf@mat.ucm.es> (raw)

[-- Attachment #1: Type: text/plain, Size: 2775 bytes --]

Hi all

I am a long term  Emacs user, and I still use bbdb-2.35[1]

I also use one of the recent packages, ox-ods exporter
https://github.com/kjambunathan/org-mode-ox-odt/blob/8242670d7192e8992ac43e3f1033f7bcce55366f/lisp/ox-ods.el#L1329
which uses `string>`. 

Due to clash between how stock `Emacs 28.1/29.2`
defines `string>` and how `bbdb` "re-defines" `string>`, I was getting
in to "weird" crash with with `ox-ods` and I hard time debugging it.

I only wish if `Emacs` could somehow catch the "error", I could
have saved myself some time (~ a week)

1. `emacs -Q`
2. Copy below snippet to `~/tmp/my-test.el`.  Note that it "re-defines" `string>` as a macro ...

--8<---------------cut here---------------start------------->8---

;;; -*- mode: emacs-lisp; lexical-binding: t; -*-

(require 'subr-x)
(require 'pcase)

(defvar my-test-fruits
  (list "apples" "oranges" ))



;; bbdb-2.35 contains the macro

(defmacro string> (a b)
  (list 'not (list 'or (list 'string= a b)
		   (list 'string< a b))))

;; (defmacro string> (a b)
;;   `(not (or (string= ,a ,b)
;;             (string< ,a ,b))))

(defun my-test-3 ()
  "Simplifed recipe without any file system APIs"
  (message "sorted result is: %S"
	   (thread-last my-test-fruits
			(pcase--flip sort #'string>))))

(my-test-3)

(provide 'my-test)
--8<---------------cut here---------------end--------------->8---


3. Byte-compile and load  my-test.elc
4. `C-x b *scratch*` and copy the below snippet in there

--8<---------------cut here---------------start------------->8---
(add-to-list 'load-path "~/tmp/")
(require 'my-test)
--8<---------------cut here---------------end--------------->8---

5. M-x toggle-debug-on-error
6. (my-test-3) C-x C-e (eval-last-sexp)

Results in 



--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (invalid-function (macro . #f(compiled-function (a b) #<bytecode 0x42f2ad11d0a9e99>)))
  (macro . #f(compiled-function (a b) #<bytecode 0x42f2ad11d0a9e99>))("oranges" "apples")
  sort(("apples" "oranges") string>)
  my-test-3()
  byte-code("\300 \210\301\302!\207" [my-test-3 provide my-test] 2)
  load("/home/oub/tmp/my-test.elc")
  byte-compile-and-load-file()
  funcall-interactively(byte-compile-and-load-file)
  call-interactively(byte-compile-and-load-file nil nil)
  command-execute(byte-compile-and-load-file)
--8<---------------cut here---------------end--------------->8---

Regards

Uwe Brauer 

-- 
I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine. 


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5684 bytes --]

             reply	other threads:[~2024-07-30 15:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30 15:16 Uwe Brauer [this message]
2024-07-30 17:44 ` Improve the byte compiler: cryptic error message, macros Michael Heerdegen via Emacs development discussions.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87msly7vwi.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.