syntax across languages
Pixel
pixel@mandrakesoft.com
11 Feb 2002 19:48:48 +0100
"C.Reinke" <C.Reinke@ukc.ac.uk> writes:
> > > encryptionTooSimple d =
> > > "This encryption key is too simple (must be at least "
> > > ++(show (d::Integer))++ characters long)"
> >
> > - i don't like separating the string from the code for simple strings
>
> if you don't extract the string, how can it be a parameter
> of/variable in your application?
(GNU) C uses xgettext which extracts the tagged strings.
All you have to do to i18n is to replace:
printf("This encryption key ... at least %d ...", ...)
with
printf(_("This encryption key ... at least %d ..."), ...)
[...]
> <GRIPE>
> one thing I really don't like about Haskell is it's lacking
> support for HERE documents, as you'll find them in shells or
> in Perl. Am I the only one who's constantly bitten by this?
> </GRIPE>
>
> <ROUGH SUGGESTION>
>
> Something like:
>
> encryptionTooSimple :: Integer -> String
> encryptionTooSimple d = <<HERE;
> This encryption key is too simple (must be at least $d characters long)
> HERE
you have 2 propositions in one: multi-line strings and interpolated strings.
* multi-line strings:
- either HERE-documents (perl, sh...)
- more complicated delimiter alike """ ... """ in python
- nestable delimiter alike qq( ... (...) ...) in perl
* interpolated strings
- dollar marked variable expanded in strings (perl, sh...)
- expression in the string alike "1+1 = #{1+1}" in Ruby
- not really string interpolation, but there is also the Python way based on
highly sugared sprintf
Of course, all this can be found at
http://merd.net/pixel/language-study/syntax-across-languages.html#Strings
:)
I think it would be a very nice addition in haskell's syntax