[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Module name mangling
From: |
Dirk Herrmann |
Subject: |
Re: Module name mangling |
Date: |
Wed, 24 Jan 2001 18:40:01 +0100 (MET) |
On Tue, 23 Jan 2001, Martin Grabmueller wrote:
> I have reworked the patch a bit, but I am not sure whether the current
> solution is better. I am still doing bit-twiddling, because (as
> Marius already pointed out), the result of the conversion has to be
> two characters.
>
> But on a second thought: maybe we only have to care about characters
> whose hex representation have two digits? ...
>
> Oh, another problem with `string->number': the resulting hex digits
> are all lowercase, which is not common practice for URL-encoding
> (don't know about the standard, but web browsers normally use
> upper-case characters).
Although Martin's solution works perfectly doing url encoding for
filenames, I now feel that such a patch would mean overdoing things: We
only have to care about a very limited set of characters, namely those
which can not be used within filenames on some systems. For all other
characters, we should not care whether they are typically hex-encoded in
urls or not, but rather try to keep filenames _readable_ as far as
possible. For example, why should a '+' character be encoded if it is
allowed within filenames on all file systems known? (Just an example, I
don't know if '+' is really allowed in filenames everywhere...)
Thus, I suggest a simple solution as the following one.
----------------------------- BEGIN ------------------------------
;;; Support for filesystem friendly encoded module names
(define (filename-encode s)
(define char-encoding-alist
'((#\% . "%25") (#\* . "%2A")))
(define (char-encode c)
(cond ((assv c char-encoding-alist) => cdr)
(else (string c))))
(apply string-append
(map char-encode
(string->list s))))
(define (symbol->encoded-filename sym)
(filename-encode (symbol->string sym)))
------------------------------ END -------------------------------
Instead of an url encoding, we could also choose a different encoding if
preferred:
(define char-encoding-alist
'((#\% . "%percent%") (#\* . "%star%")))
This would, for example, result in "and-let%star%.scm" instead of
"and-let%2A.scm", which IMO is easier to understand.
Best regards,
Dirk Herrmann
- Module name mangling, Martin Grabmueller, 2001/01/08
- Re: Module name mangling, Martin Grabmueller, 2001/01/08
- Re: Module name mangling, Dirk Herrmann, 2001/01/19
- Re: Module name mangling, Marius Vollmer, 2001/01/20
- Re: Module name mangling, Martin Grabmueller, 2001/01/23
- Re: Module name mangling,
Dirk Herrmann <=
- Re: Module name mangling, Martin Grabmueller, 2001/01/24
- Re: Module name mangling, Marius Vollmer, 2001/01/28
- Re: Module name mangling, Dirk Herrmann, 2001/01/29
- Re: Module name mangling, Dale P. Smith, 2001/01/29
- Re: Module name mangling, Dirk Herrmann, 2001/01/29
- Re: Module name mangling, Lars J. Aas, 2001/01/29
- Re: Module name mangling, Neil Jerram, 2001/01/30
- Re: Module name mangling, Ian Grant, 2001/01/30
- Re: Module name mangling, Marius Vollmer, 2001/01/29
- Re: Module name mangling, Martin Grabmueller, 2001/01/30