CHARACTER.code and STRING_GENERAL.code

5 messages Options
Embed this post
Permalink
Alexander Kogtenkov [ES]-2

CHARACTER.code and STRING_GENERAL.code

Reply Threaded More More options
Print post
Permalink
It looks like there is a type mismatch between
CHARACTER.code and STRING_GENERAL.code.
The latter is used to define other operations on strings:
in append, put_code, etc.

The types are
- in CHARACTER_XX - INTEGER_32
- in STRING_GENERAL - NATURAL_32

As there is no imlpicit conversion from INTEGER to NATURAL,
one should write the code like

    c: CHARACTER_8
    s: STRING_GENERAL
    ...
    s.append_code (c.to_character_32.natural_32_code)

that does not look straitforward compared to the expected

    s.append_code (c.code)

Would it make sense to change the declaration of CHARACTER_XX.code
be of type NATURAL_32?

Regards,
Alexander Kogtenkov

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
freeelks-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freeelks-devel
helmut.brandl

Re: CHARACTER.code and STRING_GENERAL.code

Reply Threaded More More options
Print post
Permalink
Alexander Kogtenkov wrote:

> It looks like there is a type mismatch between
> CHARACTER.code and STRING_GENERAL.code.
> The latter is used to define other operations on strings:
> in append, put_code, etc.
>
> The types are
> - in CHARACTER_XX - INTEGER_32
> - in STRING_GENERAL - NATURAL_32
>
> As there is no imlpicit conversion from INTEGER to NATURAL,

Why not? INTEGERs and NATURALs of the same bit size can be converted
without loss of information.

> one should write the code like
>
>     c: CHARACTER_8
>     s: STRING_GENERAL
>     ...
>     s.append_code (c.to_character_32.natural_32_code)
>
> that does not look straitforward compared to the expected
>
>     s.append_code (c.code)
>
> Would it make sense to change the declaration of CHARACTER_XX.code
> be of type NATURAL_32?

>From the beginning of Eiffel the most basic type has been INTEGER. Array
indices are INTEGER and not NATURAL. If you want to change CHARACTER or
STRING I would recommend to change the code in STRING to INTEGER to be
consistent.

Regards
Helmut



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
freeelks-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freeelks-devel
Emmanuel Stapf

Re: CHARACTER.code and STRING_GENERAL.code

Reply Threaded More More options
Print post
Permalink
> > As there is no imlpicit conversion from INTEGER to NATURAL,
>
> Why not? INTEGERs and NATURALs of the same bit size can be converted
> without loss of information.

Not true. You cannot convert -1 which is a valid INTEGER, but meaningless for
NATURAL.
 
> >From the beginning of Eiffel the most basic type has been INTEGER. Array
> indices are INTEGER and not NATURAL. If you want to change CHARACTER or
> STRING I would recommend to change the code in STRING to INTEGER to be
> consistent.

Actually there is a push for using NATURAL, but it has been held back due to the
breaking changes impact. And this is exactly what Alexander is pointing out.

I would add for the moment `natural_32_code' to CHARACTER_8 to make things
simpler.

Regards,
Manu


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
freeelks-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freeelks-devel
------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------  
Alexander Kogtenkov [ES]-2

Re: CHARACTER.code and STRING_GENERAL.code

Reply Threaded More More options
Print post
Permalink
In reply to this post by helmut.brandl
It looks like my reply went only to Helmut. It is repeated below:

Helmut Brandl wrote:

>> As there is no imlpicit conversion from INTEGER to NATURAL,
 
 > Why not? INTEGERs and NATURALs of the same bit size can be converted
> without loss of information.
 
 It's not that easy to convert {INTEGER_32} -1 to NATURAL_32, as well as it's
not that easy to convert {NATURAL} 0xFFFFFFFF to INTEGER_32.
 
> From the beginning of Eiffel the most basic type has been INTEGER. Array
> indices are INTEGER and not NATURAL. If you want to change CHARACTER or
> STRING I would recommend to change the code in STRING to INTEGER to be
> consistent.
 
 To the best of my knowledge Unicode code points are unsigned, so it's much
more convenient to have them unsigned in Eiffel. I think character code is more
often used as a unicode code point rather than as an index to an array.
 
 Regards,
Alexander Kogtenkov


----- Original Message -----
From: "Helmut Brandl" <[hidden email]>
To: <[hidden email]>
Sent: Thursday, September 10, 2009 7:13 PM
Subject: Re: [freeelks-devel] CHARACTER.code and STRING_GENERAL.code


> Alexander Kogtenkov wrote:
>> It looks like there is a type mismatch between
>> CHARACTER.code and STRING_GENERAL.code.
>> The latter is used to define other operations on strings:
>> in append, put_code, etc.
>>
>> The types are
>> - in CHARACTER_XX - INTEGER_32
>> - in STRING_GENERAL - NATURAL_32
>>
>> As there is no imlpicit conversion from INTEGER to NATURAL,
>
> Why not? INTEGERs and NATURALs of the same bit size can be converted
> without loss of information.
>
>> one should write the code like
>>
>>     c: CHARACTER_8
>>     s: STRING_GENERAL
>>     ...
>>     s.append_code (c.to_character_32.natural_32_code)
>>
>> that does not look straitforward compared to the expected
>>
>>     s.append_code (c.code)
>>
>> Would it make sense to change the declaration of CHARACTER_XX.code
>> be of type NATURAL_32?
>
>>From the beginning of Eiffel the most basic type has been INTEGER. Array
> indices are INTEGER and not NATURAL. If you want to change CHARACTER or
> STRING I would recommend to change the code in STRING to INTEGER to be
> consistent.
>
> Regards
> Helmut
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> freeelks-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freeelks-devel
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
freeelks-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freeelks-devel
helmut.brandl

Re: CHARACTER.code and STRING_GENERAL.code

Reply Threaded More More options
Print post
Permalink


Alexander Kogtenkov wrote:

> It looks like my reply went only to Helmut. It is repeated below:
>
> Helmut Brandl wrote:
>
>>> As there is no imlpicit conversion from INTEGER to NATURAL,
>  
>  > Why not? INTEGERs and NATURALs of the same bit size can be converted
>> without loss of information.
>  
>  It's not that easy to convert {INTEGER_32} -1 to NATURAL_32, as well as it's
> not that easy to convert {NATURAL} 0xFFFFFFFF to INTEGER_32.
>  
>> From the beginning of Eiffel the most basic type has been INTEGER. Array
>> indices are INTEGER and not NATURAL. If you want to change CHARACTER or
>> STRING I would recommend to change the code in STRING to INTEGER to be
>> consistent.
>  
>  To the best of my knowledge Unicode code points are unsigned, so it's much
> more convenient to have them unsigned in Eiffel. I think character code is more
> often used as a unicode code point rather than as an index to an array.

For character codes I agree to use NATURAL.


Regards
Helmut


>  
>  Regards,
> Alexander Kogtenkov
>
>
> ----- Original Message -----
> From: "Helmut Brandl" <[hidden email]>
> To: <[hidden email]>
> Sent: Thursday, September 10, 2009 7:13 PM
> Subject: Re: [freeelks-devel] CHARACTER.code and STRING_GENERAL.code
>
>
>> Alexander Kogtenkov wrote:
>>> It looks like there is a type mismatch between
>>> CHARACTER.code and STRING_GENERAL.code.
>>> The latter is used to define other operations on strings:
>>> in append, put_code, etc.
>>>
>>> The types are
>>> - in CHARACTER_XX - INTEGER_32
>>> - in STRING_GENERAL - NATURAL_32
>>>
>>> As there is no imlpicit conversion from INTEGER to NATURAL,
>> Why not? INTEGERs and NATURALs of the same bit size can be converted
>> without loss of information.
>>
>>> one should write the code like
>>>
>>>     c: CHARACTER_8
>>>     s: STRING_GENERAL
>>>     ...
>>>     s.append_code (c.to_character_32.natural_32_code)
>>>
>>> that does not look straitforward compared to the expected
>>>
>>>     s.append_code (c.code)
>>>
>>> Would it make sense to change the declaration of CHARACTER_XX.code
>>> be of type NATURAL_32?
>>> >From the beginning of Eiffel the most basic type has been INTEGER. Array
>> indices are INTEGER and not NATURAL. If you want to change CHARACTER or
>> STRING I would recommend to change the code in STRING to INTEGER to be
>> consistent.
>>
>> Regards
>> Helmut
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
>> trial. Simplify your report design, integration and deployment - and focus on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> freeelks-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/freeelks-devel
>>
>>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> freeelks-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freeelks-devel
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
freeelks-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freeelks-devel