develooper Front page | perl.perl5.porters | Postings from August 2008

Re: Re-gaining 'O's

Thread Previous | Thread Next
From:
Juerd Waalboer
Date:
August 27, 2008 00:31
Subject:
Re: Re-gaining 'O's
Message ID:
20080827073134.GN10987@c4.convolution.nl
Russ Allbery skribis 2008-08-26 10:42 (-0700):
> Hm.  On first glance, that implementation choice looks like it's made Perl
> much more difficult to program in

Basically, when implementing Unicode in a programming language, there
are two options.

1. Provide separate functions for multibyte encoded strings. Usually
this requires a certain specific encoding, like UTF-8.

2. Retrofit existing functions to support Unicode characters, and make
the string type support characters with higher values.

3. Provide separate functions, and separate string types, and let OO or
MMD handle it.

Option 3 is IMO the nicest solution, but Perl does not have types.
Option 1 would mean changing all code that *handles* strings, while
option 2 means changing only code that reads or writes strings. Because
good code usually does this only at boundaries, it's (by comparison) the
easiest way to add Unicode support to an existing program. I'm glad that
Perl has taken this route.

PHP initially went for option 1 (mb_*) but for PHP 6 will go for option 2.
Perl currently has option 2. Perl 6 is expected to implement a variant
of 3.

> I must admit, though, that I'm unlikely to go back and sprinkle such
> code through every module and script I maintain.

Nobody's forcing you. If you don't need Unicode support, don't add it. :)

Note that if code is properly abstracted, it's not much work. For
example, if you're using templating, you already have a single place
where most text strings are sent out.
-- 
Met vriendelijke groet,  Kind regards,  Korajn salutojn,

  Juerd Waalboer:  Perl hacker  <#####@juerd.nl>  <http://juerd.nl/sig>
  Convolution:     ICT solutions and consultancy <sales@convolution.nl>
1;

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About