From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Raku evaluation for org-babel Date: Fri, 10 Apr 2020 16:34:31 -0400 Message-ID: References: <3092014.Nvo2iUt9sp@terra> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="13897"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel To: Tim Van den Langenbergh Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 10 22:35:21 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jN0Mx-0003RZ-S4 for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Apr 2020 22:35:19 +0200 Original-Received: from localhost ([::1]:38698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jN0Mw-0007Iv-P4 for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Apr 2020 16:35:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39395) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jN0MM-0006uC-VO for emacs-devel@gnu.org; Fri, 10 Apr 2020 16:34:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jN0MK-0006nE-Iz for emacs-devel@gnu.org; Fri, 10 Apr 2020 16:34:41 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:47171) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jN0MK-0006mk-2l for emacs-devel@gnu.org; Fri, 10 Apr 2020 16:34:40 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6224644FF29; Fri, 10 Apr 2020 16:34:39 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0E2DE44FF1F; Fri, 10 Apr 2020 16:34:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1586550873; bh=VviXFbybM2Ymi3cgP/rLHo3MoeZzP760WlOBgJH1Opg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=nDS1k8vmDz401VuxZtWwhUB8DlB7mwQZi/GnLVkx7t6enRiLVGABEMW0jgQ1h1E+o yk/yF8qCP6GaP2oTBP4U7RQ2eBfC4ufysK9vkvHt/4vx/d+PGipCnlcwRPxZLE2E5q RXVZ3qnlG1PBzNkvAhafauM1TelKp4iIUJluJXcY52ZPrLgZFGDlwYUrF+Wq+HukH7 JRzeEJklELJ4Lp0Z8F+MTEZ8+XF3ggySvRI4HgTJbQvYf3Z7JVHR01Y3Ebyo1+q+uE 5skw97iGHJcqFbiKcjmYZYIayH8vDatIKQmtmEaIh1zfuuv6xQUSrMYBRqlY3Hm9cs p6mLiJjSOpppA== Original-Received: from alfajor (unknown [104.247.241.114]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A86281204F6; Fri, 10 Apr 2020 16:34:32 -0400 (EDT) In-Reply-To: <3092014.Nvo2iUt9sp@terra> (Tim Van den Langenbergh's message of "Wed, 25 Mar 2020 02:32:26 +0100") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:246802 Archived-At: > 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 > ;; 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 . > (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