emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Slashes inserted into Common Lisp code evaluation results
@ 2023-05-02  6:18 Nathan Van Ymeren
  2023-05-02 10:52 ` gerard.vermeulen
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Van Ymeren @ 2023-05-02  6:18 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

For my studies I’ve been using org as a superior form of jupyter notebook, and I do my assignments and whatnot using code blocks for computation.  My preferred language these days is Common Lisp, using the SBCL implementation.  Whereas languages like python default to using IEEE double-width floats, in Common Lisp the default type for a value like “1.0872” is a single-width float which sometimes introduces precision errors when computing many decimal places.

In Common Lisp (and probably in elisp too, but I don’t speak that dialect so idk) you can specify that a number should use double-precision floats by appending “d0” to the end, so for example 1.0872d0.

Here’s my problem:

When I specify double width floats, they appear with slashes embedded in the RESULTS blocks, like so:

#+begin_src lisp
  (+ 1 0.0002d0)
#+end_src

#+RESULTS:
: 1\.0002d0

Compare that to a single-precision float:

#+begin_src lisp
  (+ 1 0.0002)
#+end_src

#+RESULTS:
: 1.0002

What I’d like to make clear at this point is that *this is not how things look in the lisp interpreter*.  For example here’s a transcript of me doing this same thing, but not in org:

CL-USER> (+ 1 0.0002d0)
1.0002d0 (100.02d0%)

CL-USER> (+ 1 0.0002)
1.0002 (100.020004%)
CL-USER> 

You can see there’s no slash being emitted, so something in the plumbing between SBCL and org is inserting the slash.  I’m running org version 9.7_pre built from straight.el on an M-series MacBook Pro, though the same behaviour was present in the 9.x release I upgraded from.

Is this a bug?  If not, how do I suppress this behaviour?

Nate

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

* Re: Slashes inserted into Common Lisp code evaluation results
  2023-05-02  6:18 Slashes inserted into Common Lisp code evaluation results Nathan Van Ymeren
@ 2023-05-02 10:52 ` gerard.vermeulen
  2023-05-03  6:00   ` Nathan Van Ymeren
  0 siblings, 1 reply; 5+ messages in thread
From: gerard.vermeulen @ 2023-05-02 10:52 UTC (permalink / raw)
  To: Nathan Van Ymeren
  Cc: emacs-orgmode, emacs-orgmode-bounces+gerard.vermeulen=posteo.net



On 02.05.2023 08:18, Nathan Van Ymeren wrote:
> When I specify double width floats, they appear with slashes embedded
> in the RESULTS blocks, like so:
> 
> #+begin_src lisp
>   (+ 1 0.0002d0)
> #+end_src
> 
> #+RESULTS:
> : 1\.0002d0
[...]
> Is this a bug?  If not, how do I suppress this behaviour?
> 
Do you use SLIME?
I use SLY on a recent emacs-29.0.90 build with a recent org-9.7pre.
My result is (without the escaped dot):

#+begin_src lisp
(+ 1 0.0002d0)
#+end_src

#+RESULTS:
: 1.0002d0

But I needed also to patch ob-lisp, see:
https://list.orgmode.org/480536eb12bf49144384f4b1a85d8bdf@posteo.net/

In my opinion, SLY is friendlier out of the box than SLIME.

Regards -- Gerard



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

* Re: Slashes inserted into Common Lisp code evaluation results
  2023-05-02 10:52 ` gerard.vermeulen
@ 2023-05-03  6:00   ` Nathan Van Ymeren
  2023-05-03  7:14     ` gerard.vermeulen
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Van Ymeren @ 2023-05-03  6:00 UTC (permalink / raw)
  To: emacs-orgmode

Ahh, I forgot to specify.  I too use Sly in lieu of Slime, though I'm on emacs 28.  That patch does not appear to have made its way into the prerelease I’m running.  I will apply it manually later this evening and see how it goes.

Thanks,

N

May 2, 2023 03:52:52 gerard.vermeulen@posteo.net:

> 
> 
> On 02.05.2023 08:18, Nathan Van Ymeren wrote:
>> When I specify double width floats, they appear with slashes embedded
>> in the RESULTS blocks, like so:
>> #+begin_src lisp
>>   (+ 1 0.0002d0)
>> #+end_src
>> #+RESULTS:
>> : 1\.0002d0
> [...]
>> Is this a bug?  If not, how do I suppress this behaviour?
>> 
> Do you use SLIME?
> I use SLY on a recent emacs-29.0.90 build with a recent org-9.7pre.
> My result is (without the escaped dot):
> 
> #+begin_src lisp
> (+ 1 0.0002d0)
> #+end_src
> 
> #+RESULTS:
> : 1.0002d0
> 
> But I needed also to patch ob-lisp, see:
> https://list.orgmode.org/480536eb12bf49144384f4b1a85d8bdf@posteo.net/
> 
> In my opinion, SLY is friendlier out of the box than SLIME.
> 
> Regards -- Gerard


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

* Re: Slashes inserted into Common Lisp code evaluation results
  2023-05-03  6:00   ` Nathan Van Ymeren
@ 2023-05-03  7:14     ` gerard.vermeulen
  2023-05-03  7:45       ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: gerard.vermeulen @ 2023-05-03  7:14 UTC (permalink / raw)
  To: Nathan Van Ymeren
  Cc: emacs-orgmode, emacs-orgmode-bounces+gerard.vermeulen=posteo.net

Igor, merged the patch yesterday with the bugfix branch.
It is now in https://elpa.gnu.org/devel/org-9.7pre0.20230502.124756.tar 
or later.

It should not matter whether you are using Emacs-28 or Emacs-29.

Regards -- Gerard

On 03.05.2023 08:00, Nathan Van Ymeren wrote:
> Ahh, I forgot to specify.  I too use Sly in lieu of Slime, though I'm
> on emacs 28.  That patch does not appear to have made its way into the
> prerelease I’m running.  I will apply it manually later this evening
> and see how it goes.
> 
> Thanks,
> 
> N
> 
> May 2, 2023 03:52:52 gerard.vermeulen@posteo.net:
> 
>> 
>> 
>> On 02.05.2023 08:18, Nathan Van Ymeren wrote:
>>> When I specify double width floats, they appear with slashes embedded
>>> in the RESULTS blocks, like so:
>>> #+begin_src lisp
>>>   (+ 1 0.0002d0)
>>> #+end_src
>>> #+RESULTS:
>>> : 1\.0002d0
>> [...]
>>> Is this a bug?  If not, how do I suppress this behaviour?
>>> 
>> Do you use SLIME?
>> I use SLY on a recent emacs-29.0.90 build with a recent org-9.7pre.
>> My result is (without the escaped dot):
>> 
>> #+begin_src lisp
>> (+ 1 0.0002d0)
>> #+end_src
>> 
>> #+RESULTS:
>> : 1.0002d0
>> 
>> But I needed also to patch ob-lisp, see:
>> https://list.orgmode.org/480536eb12bf49144384f4b1a85d8bdf@posteo.net/
>> 
>> In my opinion, SLY is friendlier out of the box than SLIME.
>> 
>> Regards -- Gerard


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

* Re: Slashes inserted into Common Lisp code evaluation results
  2023-05-03  7:14     ` gerard.vermeulen
@ 2023-05-03  7:45       ` Ihor Radchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2023-05-03  7:45 UTC (permalink / raw)
  To: gerard.vermeulen
  Cc: Nathan Van Ymeren, emacs-orgmode,
	emacs-orgmode-bounces+gerard.vermeulen=posteo.net

gerard.vermeulen@posteo.net writes:

> Igor, merged the patch yesterday with the bugfix branch.

Main, not bugfix.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2023-05-03  7:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-02  6:18 Slashes inserted into Common Lisp code evaluation results Nathan Van Ymeren
2023-05-02 10:52 ` gerard.vermeulen
2023-05-03  6:00   ` Nathan Van Ymeren
2023-05-03  7:14     ` gerard.vermeulen
2023-05-03  7:45       ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).