unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: "Dr. Arne Babenhauserheide" <arne_bab@web.de>
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] add language/wisp to Guile?
Date: Sun, 5 Feb 2023 16:08:00 +0100	[thread overview]
Message-ID: <1a70460e-11fb-9f5d-0d5f-1eb507d5af0d@telenet.be> (raw)
In-Reply-To: <87357ldqaq.fsf@web.de>


[-- Attachment #1.1.1: Type: text/plain, Size: 6790 bytes --]



On 04-02-2023 22:35, Dr. Arne Babenhauserheide wrote:
> 
> Maxime Devos <maximedevos@telenet.be> writes:
> 
>>> This needs an addition to the extensions via guile -x .w — I wrote
>>> that
>>> in the documentation. I didn’t want to do that unconditionally, because
>>> detecting a wisp file as scheme import would cause errors.
>>
>> If done carefully, I don't think this situations would happen.
>> More precisely:
>>
>>    * .w would be in the file extensions list.
>>
>>    * Instead of a list, it would actually be a map from extensions to
>>      languages:
>>
>>        .scm -> scheme
>>        .w -> wisp
>>
>>      With this change, (use-modules (foo)) will load 'foo.scm' as Scheme
>>      and 'foo.w' as Wisp.  (Assuming that foo.go is out-of-date or
>>      doesn't exist.)
>>
>>      (For backwards compatibility, I think %load-extensions needs to
>>      remain a list of strings, but a %extension-language variable could
>>      be defined.)
>>
>>    * "guile --language=whatever foo" loads foo as whatever, regardless
>>      of the extension of 'foo' (if a specific language is requested,
>>      then the user knows best).
>>
>>    * "guile foo" without --language will look up the extension of foo in
>>      the extension map. If an entry exists, it would use the
>>      corresponding language.  If no entry exists, it would use
>>      a default language (scheme).
> 
> This sounds good, though a bit more complex than I think it should be.
> 
> I think this should stick to only load Scheme if no language is detected
> to keep Scheme the default language for Guile

To my knowledge, this is the case in my proposal.  Detecting the 
language is done via the file extension, and if no known mapping exists, 
it defaults to Scheme.

> — and also to avoid
> stumbling over files that just take that extension.

While I suppose it is theoretically possible someone will write a .w 
file that contains Scheme code instead of Wisp, I'm not convinced by 
this argument.  It sounds very unlikely, and also a 'don't do that, 
then' situation.

> Checking more files
> could slow down startup and I think having multiple languages fully
> equal would risk splintering the development community.
> 
> Guile is first and foremost Scheme and fast startup time is essential.
> 
> More complicated is what should be done if a *.go file is detected
> during import. There I could see Guile check if a file with any
> supported extension is up to date.

Maybe the .go could contain some information on what the corresponding 
source code file name is, and Guile could read the .go without checking 
first checking for up-to-dateness. (But only reading; not loading yet!)

(There is already debugging information with such information, but to my
understanding that's for individual procedures, not the .go as a whole, 
and by using stuff like 'include' or macros there can be multiple source 
files.)

Once read, it should be easy to look up the source code file name from 
the .go and then verify whether the .go is up to date, and proceed with 
actually loading the .go (as in, put stuff in the module system, run 
top-level code, ...).

IIUC, that would be fully backwards compatible, and not cause any 
non-negligible slowdowns.

I also have an alternative proposal, more complicated and 
backwards-incompatible -- I wouldn't recommend it, but for completeness:

  * when doing (use-module (foo)) and foo.go exists in the
    $GUILE_LOAD_COMPILED_PATH, load it, and don't
    bother checking whether foo.scm, foo.w or foo.whatever exists
    or is up-to-date.  (If not done already in Guile.)

That should solve the 'I don't care what language the library Foo is 
written in, and my library Bar isn't written in Wisp so it seems 
unreasonable to have to add -x w.’, and would also avoid the need for a 
'extension -> language map' thing.  It should also be a little faster 
than what we had before.

That's for "make install", "apt-get install", "guix install" ...-like 
uses of compiled .go -- let's call them 'installed .go'.  It won't work 
for ~/.cache/guile/ccache/3.0-LE-8-4 (‘cached .go’) as for that it's 
actually important to check up-to-dateness because, well, cache.

Additionally, to support compiling software that is already installed, 
there needs to be an option to treat certain modules with the 'cache' 
behaviour even if not in the actual ~/.cache, maybe with some 
'--local-module=(stuff ...)' option (name pending).

This would be backwards-incompatible, but it could be done.

>>> readable uses
>>
>> This sentence appears to be incomplete; I might have misinterpreted it
>> below (I don't know what you mean with 'readable' -- its an adjective
>> and you are using it as a noun?).
> 
> readable is a noun, yes: the readable lisp project.

Looks like you meant this: <https://readable.sourceforge.io/>.
>>> Can I write it into a string and then read it back?
>>
>> No.  [...]
> 
> This sounds like I cannot go that way, because there’s a necessary
> pre-processing step in wisp-read via (match-charlist-to-repr peeked):
> [...] > This actually needs to be able to write the replacement symbols back
> into the port.
>
>> ..., for which I proposed a replacement, so do you still need to turn
>> it in a string & back?
> 
> Sadly yes. Otherwise the normal reader will play tricks on the code,
> because it does not know where a symbol needs to be interpreted
> differently (i.e. where ` needs to be treated as `() even though that’s
> not in the string).

OK, too bad.  Looks like the REPR-... stuff is to stay for now.
> I meant this:
> 
> (define (foo)
>    #((bar . baz))
>    #f)
> (procedure-properties foo)
> => ((name . foo) (bar . baz))
> 
> I use that for doctests: [...]

I didn't know that these literal vectors get turned into procedure 
properties ... looks interesting.

Also, about wisp-unescape-underscore-and-colon and the 'only unescapes 
up to 12 leading underscores at line start (\____________)' limitation: 
I have found a solution: you can use a combination of string-every, 
symbol->string, string->symbol, substring and string-ref:

(cond ((list? code) (map wisp-... code))
       ((eq? code '\:) ':)
       ;; Look for symbols like \____ and remove the \.
       ((symbol? code)
        (let ((as-string (symbol->string code)))
          (if (and (>= (string-length as-string) 2) ; at least a single 
underscore
                   (char=? (string-ref as-string 0) #\\)
                   (string-every #\_ (substring as-string 1)))
              (string->symbol (substring as-string 1))
              code)))
      (#true code))

Greetings,
Maxime.

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2023-02-05 15:08 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 21:26 [PATCH] add language/wisp to Guile? Dr. Arne Babenhauserheide
2023-02-04 15:08 ` Maxime Devos
2023-02-04 15:46   ` Dr. Arne Babenhauserheide
2023-02-04 19:09     ` Maxime Devos
2023-02-04 21:35       ` Dr. Arne Babenhauserheide
2023-02-05 15:08         ` Maxime Devos [this message]
2023-02-14  8:32           ` Dr. Arne Babenhauserheide
2023-02-14 21:24             ` Dr. Arne Babenhauserheide
2023-02-14 23:01               ` Maxime Devos
2023-02-15  1:46                 ` Matt Wette
2023-02-16 21:38                   ` Dr. Arne Babenhauserheide
2023-02-17  1:26                     ` Matt Wette
2023-02-23 11:36                       ` Ludovic Courtès
2023-02-23 17:48                         ` Dr. Arne Babenhauserheide
2023-02-23 18:42                         ` Maxime Devos
2023-02-24 15:45                           ` Ludovic Courtès
2023-02-24 16:34                             ` Dr. Arne Babenhauserheide
2023-03-08 10:34                               ` Dr. Arne Babenhauserheide
2023-05-01  9:54                                 ` [PATCH] add SRFI-119 / language/wisp to Guile? (new patch, squashed) Dr. Arne Babenhauserheide
2023-06-10 16:40                                   ` Ludovic Courtès
2023-06-12 10:22                                     ` Maxime Devos
2023-08-10  6:28                                       ` Dr. Arne Babenhauserheide
2023-08-14 20:11                                         ` Dr. Arne Babenhauserheide
2023-08-14 20:30                                           ` Dr. Arne Babenhauserheide
2023-08-14 22:43                                           ` Dr. Arne Babenhauserheide
2023-08-18 10:29                                           ` Ludovic Courtès
2023-08-18 12:16                                             ` Dr. Arne Babenhauserheide
2023-08-18 17:50                                               ` Dr. Arne Babenhauserheide
2023-09-08 17:46                                               ` Dr. Arne Babenhauserheide
2023-10-05 14:10                                                 ` Dr. Arne Babenhauserheide
2023-10-10 23:04                                                   ` Dr. Arne Babenhauserheide
2023-10-27 22:05                                                     ` Dr. Arne Babenhauserheide
2024-01-09  7:05                                                       ` Dr. Arne Babenhauserheide
2024-01-19  8:21                                                         ` Dr. Arne Babenhauserheide
2024-03-11  1:16                                                           ` [PATCH] add SRFI-119 / language/wisp to Guile? (new patch with more tests, squashed) Dr. Arne Babenhauserheide
2024-06-01  9:57                                                             ` Ludovic Courtès
2024-06-01 15:06                                                               ` Dr. Arne Babenhauserheide
2024-06-07  5:44                                                                 ` Damien Mattei
2024-06-10  8:13                                                                   ` [PATCH] add SRFI-119 / language/wisp to Guile? (new patch withmore " Maxime Devos
2024-06-10 23:03                                                                     ` Damien Mattei
2024-06-13 20:29                                                                   ` [PATCH] add SRFI-119 / language/wisp to Guile? (new patch with more " Dr. Arne Babenhauserheide
2024-01-19 12:10                                                         ` [PATCH] add SRFI-119 / language/wisp to Guile? (new patch, squashed) Christina O'Donnell
2024-01-19 21:37                                                           ` Ricardo Wurmus
2024-01-19 21:47                                                             ` Christina O'Donnell
2024-01-20 11:01                                                               ` Damien Mattei
2024-01-20 19:18                                                                 ` Dr. Arne Babenhauserheide
2024-01-20 22:59                                                                   ` Damien Mattei
2024-01-20 23:22                                                                     ` Dr. Arne Babenhauserheide
2024-01-21 23:21                                                                       ` Damien Mattei
2024-01-19 23:56                                                           ` Dr. Arne Babenhauserheide
2023-02-24 23:48                             ` [PATCH] add language/wisp to Guile? Maxime Devos
2023-02-24 23:51                               ` Maxime Devos
2023-02-25  0:15                                 ` Matt Wette
2023-02-25 10:42                                   ` Maxime Devos
2023-02-17 23:06                     ` Maxime Devos
2023-02-18  3:50                       ` Philip McGrath
2023-02-18 15:58                         ` Maxime Devos
2023-02-18 19:56                           ` Matt Wette
2023-02-21 12:09                             ` Dr. Arne Babenhauserheide
2023-02-26  7:45                           ` Philip McGrath
2023-02-26 15:42                             ` Maxime Devos
2023-02-26 16:14                               ` Dr. Arne Babenhauserheide
2023-02-26 17:58                               ` Matt Wette
2023-02-26 18:03                                 ` Dr. Arne Babenhauserheide
2023-02-26 18:20                                   ` Matt Wette
2023-02-26 21:39                                     ` Dr. Arne Babenhauserheide
2023-10-02 14:59                             ` Christine Lemmer-Webber
2023-10-02 21:46                               ` guile support for multiple languages [was: [PATCH] add language/wisp to Guile?] Matt Wette
2023-02-23  7:59                         ` [PATCH] add language/wisp to Guile? Maxime Devos
2023-02-23  8:51                           ` Dr. Arne Babenhauserheide
2023-02-23 18:04                             ` Maxime Devos
2023-02-23 18:22                               ` Maxime Devos
2023-02-23 18:36                               ` Maxime Devos
2023-02-23 18:37                               ` Maxime Devos
2023-02-15  8:36                 ` Dr. Arne Babenhauserheide
2023-02-15 20:13                   ` Maxime Devos
2023-02-16  7:01                     ` Dr. Arne Babenhauserheide
2023-02-16  8:03   ` Dr. Arne Babenhauserheide
2023-02-16 11:30     ` Maxime Devos
2023-02-16 21:35       ` Dr. Arne Babenhauserheide
2023-09-30 13:17 ` Christine Lemmer-Webber
2023-09-30 20:09   ` Maxime Devos
2023-10-02 14:48     ` Christine Lemmer-Webber
     [not found] <mailman.886.1677397547.13386.guile-devel@gnu.org>
2023-02-26 11:02 ` Marc Nieper-Wißkirchen
2023-02-26 23:22   ` Philip McGrath
2023-02-27  5:00     ` Dr. Arne Babenhauserheide
2023-02-27  7:26     ` Marc Nieper-Wißkirchen
2023-02-28  4:27       ` Philip McGrath
2023-02-28  6:57         ` Marc Nieper-Wißkirchen

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/guile/

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

  git send-email \
    --in-reply-to=1a70460e-11fb-9f5d-0d5f-1eb507d5af0d@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=arne_bab@web.de \
    --cc=guile-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.
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).