Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 2 > Newsgroup comp.lang.oberon

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 09-21-2011, 01:56 PM
August Karlstrom
Guest
 
Posts: n/a
Default The empty string in Oberon-07/11

In the new 2011 revision of Oberon-07, character literals where removed
and instead single-character strings are now compatible with character
variables. Still, I find it hard to reason about expressions involving
the empty string like

ch = 0X (*has to be valid*)
ch = "" (*valid?*)

using the stated rules of the language (rather than intuition). How can
I conclude that the empty string is compatible with a character
variable? Where does it say that a character variable can be compared
with a single-character string or the empty string? Can somebody help me?


August

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 09-21-2011, 02:42 PM
August Karlstrom
Guest
 
Posts: n/a
Default Re: The empty string in Oberon-07/11

On 2011-09-21 15:56, August Karlstrom wrote:
> In the new 2011 revision of Oberon-07, character literals where removed
> and instead single-character strings are now compatible with character
> variables. Still, I find it hard to reason about expressions involving
> the empty string like
>
> ch = 0X (*has to be valid*)
> ch = "" (*valid?*)
>
> using the stated rules of the language (rather than intuition). How can
> I conclude that the empty string is compatible with a character
> variable? Where does it say that a character variable can be compared
> with a single-character string or the empty string? Can somebody help me?


I think I got the first part now. The literal 0X is a single-character
string but its length is zero. The expression ch = "" must be invalid.
My mistake was to think of 0X as the empty string. These examples may
clarify the concepts:

"hello" (*five-character string of length five*)
"A" (*single-character string of length one*)
0X (*single-character string of length zero*)
"" (*zero-character string of length zero*)


August

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
Reply With Quote
  #3 (permalink)  
Old 09-23-2011, 01:50 PM
Chris Burrows
Guest
 
Posts: n/a
Default Re: The empty string in Oberon-07/11

"August Karlstrom" <fusionfile@gmail.com> wrote in message
news:j5cqf2$qm1$1@dont-email.me...
>
>Where does it say that a character variable can be compared with a
>single-character string or the empty string?


There are several examples of single-character strings being compared with
character variables included in the report:

e.g. Section 9.4:
IF (ch >= "A") & (ch <= "Z") THEN ReadIdentifier

You have already answered the empty string part of the question yourself.

Regards,
Chris Burrows

CFB Software
Astrobe v3.4: ARM Oberon Development System
http://www.astrobe.com





Reply With Quote
  #4 (permalink)  
Old 09-23-2011, 03:33 PM
August Karlstrom
Guest
 
Posts: n/a
Default Re: The empty string in Oberon-07/11

On 2011-09-23 15:50, Chris Burrows wrote:
> There are several examples of single-character strings being compared with
> character variables included in the report:
>
> e.g. Section 9.4:
> IF (ch>= "A")& (ch<= "Z") THEN ReadIdentifier


Yes, but it is not stated in section 8.2.4 about relations (strings are
not mentioned at all). Maybe Prof Wirth reasons that the validity of
string comparisons is implied by the assignment compatibility between
single-character strings and character variables and between strings and
character arrays.


August

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
Reply With Quote
  #5 (permalink)  
Old 09-23-2011, 11:22 PM
Chris Burrows
Guest
 
Posts: n/a
Default Re: The empty string in Oberon-07/11

"August Karlstrom" <fusionfile@gmail.com> wrote in message
news:j5i8so$4p6$1@dont-email.me...
> On 2011-09-23 15:50, Chris Burrows wrote:
>> There are several examples of single-character strings being compared
>> with
>> character variables included in the report:
>>
>> e.g. Section 9.4:
>> IF (ch>= "A")& (ch<= "Z") THEN ReadIdentifier

>
> Yes, but it is not stated in section 8.2.4 about relations (strings are
> not mentioned at all). Maybe Prof Wirth reasons that the validity of
> string comparisons is implied by the assignment compatibility between
> single-character strings and character variables and between strings and
> character arrays.
>


Yes - IMO it fits into the category mentioned at the beginning of the report
"...because it is derivable from stated rules of the language...". I would
have much more difficulty in believing the alternative possibility that you
might be able to store a value in a variable but not be able to inspect its
value.


Reply With Quote
  #6 (permalink)  
Old 09-28-2011, 09:30 PM
August Karlstrom
Guest
 
Posts: n/a
Default Re: The empty string in Oberon-07/11

On 2011-09-21 16:42, August Karlstrom wrote:
> These examples may clarify the concepts:
>
> "hello" (*five-character string of length five*)
> "A" (*single-character string of length one*)
> 0X (*single-character string of length zero*)
> "" (*zero-character string of length zero*)


After having gained a little more insight I can conclude that the null
string (0X) is of length one but in all array contexts it will turn into
the empty string so to speak. Though being of pure theoretical interest,
this means that it is impossible to correctly compute the length of the
null string; for instance, the function procedure call
Strings.Length(0X) will evaluate to zero.


August

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 10:32 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.