[squeak-dev] Unicode

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Wed Sep 9 21:16:17 UTC 2020


Hi Levente,


basically, I only would like to get rid of the class variables for every single Unicode category because they provide low explorability (it's hard to work with the numeric output of #generalCategoryOf:) and extensibility (you need to recompile the class definition for adding UTF-16 support). If you are critical of increasing the size of the SparseLargeTable, I think we would also just make one or two extra dictionaries to map every category symbol to a number and vice versa. What do you think?


Best,

Christoph


________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Levente Uzonyi <leves at caesar.elte.hu>
Gesendet: Dienstag, 8. September 2020 21:43:56
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] Unicode

Hi Christoph,

On Tue, 8 Sep 2020, Thiede, Christoph wrote:

>
> Hi all,
>
>
> > Your words suggest that it has already been published, but I can't find it anywhere.
>
>
> Then I must have expressed myself wrong. I did not yet publish any code changes, but in my original post from March, you can find a short description of the design changes I'd like to implement. Essentially, I would like to
> replace the separate class variables for every known character class in favor of greater flexibility.

How would your changes affect GeneralCategory? Would it still be a
SpareLargeTable with ByteArray as arrayClass?
If you just replace those integers with symbols, the size of the table
will be at least 4 or 8 times larger in 32 or 64 bit images,
respectively.


Levente.

>
> Eliot, are there any remaining questions regarding the VM size? Character size should be sufficient as discussed below, and of course, I can test any changes in a 32-bit image, too. :-)
>
> WideString withAll: (#(42r2l 16r1F497 16r1F388 33) collect: #asCharacter)
>
> Best,
> Christoph
>
> _________________________________________________________________________________________________________________________________________________________________________________________________________________________________
> Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Tobias Pape <Das.Linux at gmx.de>
> Gesendet: Sonntag, 6. September 2020 21:00:14
> An: The general-purpose Squeak developers list
> Betreff: Re: [squeak-dev] Unicode
>
> > On 06.09.2020, at 20:40, Levente Uzonyi <leves at caesar.elte.hu> wrote:
> >
> > On Sun, 6 Sep 2020, Tobias Pape wrote:
> >
> >>
> >>> On 06.09.2020, at 19:15, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> >>> Hi Christoph, Hi All,
> >>>> On Mar 17, 2020, at 3:51 PM, Thiede, Christoph <Christoph.Thiede at student.hpi.uni-potsdam.de> wrote:
> >>>> Hi all! :-)
> >>>> After some recent fun with the Unicode class, I found out that its data is quite out of date (for example, the comments do not even "know" that code points can be longer than 4 bytes. Younger characters such as 😺❤🤓
> are not categorized correctly, etc. ...). Luckily, there is already some logic to fetch the latest data from www.unicode.org<http://www.unicode.org>. I'm currently reworking this logic because it's not completely automated yet and has some slips,
> but so long, I have one general question for you:
> >>> And consequently I have a couple of questions for you. In the Spur VM Characters are immediate (they are like SmallInteger and exist in oops (object-oriented pointers) as tagged values).  In the 32-bit variant Characters
> are 30-bit unsigned integers.  In the 64-bit variant they are also 30-bit unsigned integers, but could easily be extended to be up to 61-bit unsigned integers.
> >>> Q1, can you arrange that the Unicode support does not break in initialization on the 32-bit variant?  It may be that the 32-bit variant cannot represent code points beyond 30 bits in size, but we should try to ensure that
> initialization still runs to completion even if it fails to initialize information relating to code points beyond 30 bits in size.
> >>> Q2, how many bits should the 64-bit variant VM support for immediate Characters?
> >>
> >> Unicode has a max value of 0x10FFFF. That makes 21 bit. So no worries there.
> >>
> >> We should just not forget the leading-char stuff (Yoshiki, Andreas,...)
> >
> > AFAIU the leading char only makes sense when you have multiple CJK(V?) languages in use at the same time. In other cases Unicode (leadingChar = 0) is perfectly fine.
> > IIRC there are 22 bits available for the codePoint and 8 for the leadingChar, so we're still good: all unicode characters fit.
> >
> >
>
> \o/ hooray!
>
> > Levente
> >
> >>
> >>
> >> BEst regards
> >>       -Tobias
> >>
> >>> Then something to consider is that it is conceptually possible to support something like WideCharacter, which would represent code points outside of the immediate Character range on the 32-bit variant, analogous to
> LargePositiveInteger beyond SmallInteger maxVal.  This can be made to work seamlessly, just as it does currently with integers, and with Floats where SmallFloat64 is only used on 64-bits.
> >>> It has implications in a few parts of the system:
> >>> - failure code for WideString (VeryWideString?) at:[put:] primitives that would have to manage overflow into/access from WideCharacter instances
> >>> - ImageSegment and other (un)pickling systems that need to convert to/from a bit-specific “wire” protocol/representation
> >>> - 32-bit <=> 64-bit image conversion All this is easily doable (because we have models of doing it for Float and Integer general instances).  But we need good specifications so we can implement the right thing from the
> get-go.
> >>>> At the moment, we have 30 class variables each for one Unicode category number. These class vars map in alphabetical order to the integers from 0 to: 29. Is this tedious structure really necessary? For different
> purposes, I would like to get the category name of a specific code point from a client. The current design makes this impossible without writing additional mappings.
> >>>> Tl;dr: I would like to propose to drop these class variables and use Symbols instead. They are comparable like integers, and as they are flyweights, this should not be a performance issue either. Of course,
> #generalCategoryOf: will have to keep returning numbers, but we could deprecate it and use a new #generalTagOf: in the future. Furthermore, this would also allow us to deal with later added category names (though I don't know
> whether this will ever happen).
> >>>> Examples:
> >>>> Unicode generalTagOf: $a asUnicode. "#Ll"
> >>>> Unicode class >> isLetterCode: charCode
> >>>>  ^ (self generalTagOf: charCode) first = $L
> >>>> Unicode class >> isAlphaNumericCode: charCode
> >>>>  | tag|
> >>>>  ^ (tag := self generalCategoryOf: charCode) first = $L
> >>>>        or: [tag = #Nd]
> >>>> How do you think about this proposal? Please let me know and I will go ahead! :D
> >>>> Best,
> >>>> Christoph
> >>> Best, Eliot
> >>> _,,,^..^,,,_ (phone)
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200909/22916541/attachment.html>


More information about the Squeak-dev mailing list