guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] add language/wisp to Guile?


From: Maxime Devos
Subject: Re: [PATCH] add language/wisp to Guile?
Date: Sat, 25 Feb 2023 11:42:18 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.0



On 25-02-2023 01:15, Matt Wette wrote:
On 2/24/23 3:51 PM, Maxime Devos wrote:
On 25-02-2023 00:48, Maxime Devos wrote:
(**) For compatibility with Racket, it's not like we couldn't
implement both "#lang" and "-*- stuff: language -*-".

TBC, I mean ‘only support #lang' for values of 'lang' that Racket supports’, or alternatively ‘support #lang for compatibility, but recommend -*- ... -*- in the Guile manual.’.

The point of this is to tell the compiler what language it needs to parse,
if not the default (Scheme).  Using `#lang pascal' or `#!lang pascal' allows
the compiler to figure this out in the first few characters read. Using
`-*- lang: pascal -*-' might require the compiler to read a lot of text (not knowing if what text is comment or not) to determine if language has been specified.
For the `-*-' based design, is there a maximum number of characters to be
read before deciding?

Guile already searches for '-*- ... -*-' lines, as mentioned in a previous message:

(*) The port encoding detection supports "-*- coding: whatever -*-",
presumably that functionality could be reused.

As such, it shouldn't incur an overly large cost to support '-*- something: modula -*-' too.

On the character limit: according to Emacs documentation, there is a line limit: the '-*- ... -*-' must be on the first line. (See: ‘(emacs)Specifying File Variables’.) This seems the same situation like '#lang' to me; not ‘a lot of text’.

A more explicit character limit of 'first few hundred bytes' is mentioned in see the documentation of 'file-encoding':

 -- Scheme Procedure: file-encoding port
 -- C Function: scm_file_encoding (port)
     Attempt to scan the **first few hundred bytes** from the PORT for
     hints about its character encoding.  Return a string containing the
     encoding name or ‘#f’ if the encoding cannot be determined.  The
     port is rewound.

     Currently, the only supported method is to look for an Emacs-like
     character coding declaration (*note how Emacs recognizes file
     encoding: (emacs)Recognize Coding.).  The coding declaration is of
     the form ‘coding: XXXXX’ and must appear in a Scheme comment.
     Additional heuristics may be added in the future.

Greetings,
Maxime.

Attachment: OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]