unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Tim Van den Langenbergh <tmt_vdl@gmx.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Raku evaluation for org-babel
Date: Fri, 10 Apr 2020 16:34:31 -0400	[thread overview]
Message-ID: <jwv4ktrw6lp.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <3092014.Nvo2iUt9sp@terra> (Tim Van den Langenbergh's message of "Wed, 25 Mar 2020 02:32:26 +0100")

> I have spitballed together a module that adds Raku (formerly known as
> Perl 6) evaluation to Org-Babel.
> According to the org-babel docs I should contact this mailing list for
> help to get it ready for inclusion on elpa.

I'm not very familiar with Org-Babel, so I was wondering if it's best to
distribute such packages as standalone packages or include them in
Org-Babel, but if the org-babel doc pointed you here, I guess that's the
place they prefer, which is fine by me.

> This is my first module for Emacs, so I'm not familiar with proper
> process, I believe I have to add the .el file to this e-mail, so
> I shall do so.

Actually, if you have public Git branch somewhere, it's better, this way
we can preserve the (pre)history.

> If there is anything I have to do before I can proceed, I would be
> grateful for any advise offered.

See some comments below but the main issue is that it seems you haven't
signed the needed copyright paperwork yet.  I'll send you the forms
off-list for that.

> ;; Author: Tim Van den Langenbergh <tmt_vdl@gmx.com>
> ;; Keywords: literate programming, reproducible research
> ;; Homepage: https://github.com/tmtvl/ob-raku
> ;; Version: 0.05

This is equal to 0.5 (GNU ELPA's versions are lists of numbers and 05 is
the same number as 5).

It'd be good to add a `Package-Requires: ((emacs "NN"))` to clarify
with which versions of Emacs it's supposed to work.

> ;; News: 0.05 --- Added initial support for parentheses and commas in strings in lists without breaking the lists on return.
> ;;       0.04 --- Added square brackets to list splitting, so as to split embedded arrays as well as lists.
> ;;       0.03 --- Removed the double execution, simplified the formatting of the Raku output, fixed hline support.
> ;;       0.02 --- Added support for tables, removed unneeded require statements, error when trying to use a session.
> ;;       0.01 --- Initial release. Accept inputs, support for output and value results.

We usually prefer to put the news in a separate ";;;; News" section.
Also we recommend to avoid using more than 80 columns.

> ;; You should have received a copy of the GNU General Public License
> ;; along with GNU Emacs; see the file COPYING.  If not, write to the
> ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
> ;; Boston, MA 02110-1301, USA.

This has been updated to:

    ;; You should have received a copy of the GNU General Public License
    ;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

> (add-to-list 'org-babel-tangle-lang-exts '("raku" . "raku"))

IIUC this is the part that tells org-babel about the existence of support
for raku, but it's only executed if `ob-raku` is loaded.

It'd be nice to make it so that the user doesn't need to explicitly
require `ob-raku`, i.e. advertise the existence of raku support to
org-babel before the file is loaded.  For that you'll want to add
some ;;;###autoload cookies at a few appropriate places.

Sadly, the above `add-to-list` can't be autoloaded as-is since it will
will signal error if executed before `org-babel-tangle-lang-exts` is defined.
I don't know how it's supposed to be done for org-babel, so you may need
to ask the org-babel about that.

>     (mapconcat
> 	   (lambda (string)
> 	     (cond
> 	      ((string= string "\"")
> 	       (setq in-string (not in-string))
> 	       string)
> 	      ((and
> 		in-string
> 		(or
> 		 (string= string "(")
> 		 (string= string ")")
> 		 (string= string "[")
> 		 (string= string "]")
> 		 (string= string ",")))

Last few lines => (member string '("(" ")" "[" "]" ","))

> 	       (concat "\\" string))
> 	      (t string)))
> 	   (split-string list "" t)
> 	   "")))

Turning your string into a list of single-char strings is terribly
wasteful.  Every char in your original string will end up occupying
something like:
- 2 words for the cons cell.
- 4 words for the actual Lisp_String object.
- 2 words for the actual string bytes (1 word of header, 1 byte for the
  char, 1 terminating NUL byte, plus alignment padding).
So 8 words per char, which on a 64bit system means 64 bytes per char.

It also makes the subsequent tests more expensive since
`(string= string "(")` takes significantly more effort than (eq char ?\().

>   ;;(replace-regexp-in-string "\\\\\([][(),]\)" "\1" string) ;; This doesn't work.
                                     ^^       ^^   ^^^
                                     \\(     \\)   "\\1"?

\( and \) in a string are not special, so they're treated just like
( and ) and the regexp engine never sees your backslash!

> 	    (and (stringp (car sanitized-table))
> 		 (string= (car sanitized-table) "HLINE"))

Aka (equal (car sanitized-table) "HLINE")


        Stefan




  parent reply	other threads:[~2020-04-10 20:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25  1:32 Raku evaluation for org-babel Tim Van den Langenbergh
2020-04-09  3:14 ` Bruno Félix Rezende Ribeiro
2020-04-10 10:51   ` Tim Van den Langenbergh
2020-04-10 20:34 ` Stefan Monnier [this message]
2020-04-10 20:36   ` Stefan Monnier
2020-04-11 13:57   ` Tim Van den Langenbergh

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwv4ktrw6lp.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=tmt_vdl@gmx.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).