all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Improve the byte compiler: cryptic error message,  macros
@ 2024-07-30 15:16 Uwe Brauer
  2024-07-30 17:44 ` Michael Heerdegen via Emacs development discussions.
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Brauer @ 2024-07-30 15:16 UTC (permalink / raw)
  To: emacs-devel

[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Improve the byte compiler: cryptic error message,  macros
  2024-07-30 15:16 Improve the byte compiler: cryptic error message, macros Uwe Brauer
@ 2024-07-30 17:44 ` Michael Heerdegen via Emacs development discussions.
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Heerdegen via Emacs development discussions. @ 2024-07-30 17:44 UTC (permalink / raw)
  To: emacs-devel

Hello Uwe,

here is a smaller recipe:

#+begin_src emacs-lisp
(defmacro string> (a b)
  (list 'not (list 'or (list 'string= a b)
		   (list 'string< a b))))

(sort (list "2" "1") #'string>)
#+end_src

> [...] Results in 
>
>
> 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>)

But this is crystal clear to me: `sort' expects a function, while a
macro has been specified.  What exactly is your wish or suggestion?


Michael.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-30 17:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-30 15:16 Improve the byte compiler: cryptic error message, macros Uwe Brauer
2024-07-30 17:44 ` Michael Heerdegen via Emacs development discussions.

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.