Change of case 
Author Message
 Change of case

The Win32Forth words UPPER and LOWER are very useful,
and presumably some or all of their functionality is
included in any ANS system. There are no Standardized
word names or Standardized behaviors for accomplishing
this, but shouldn't there be? In order to assure the
portability of ftranxxx I had to implement them, but
would have vastly preferred to use the system words,
if I knew what they were.

\ example of UPPER and LOWER in action

: $"      [CHAR] "  text  ;    \ use as $" abcd"  ok

        $" abcd"  ok.
        count type abcd ok
        pad count upper  ok
        pad count type ABCD ok
        pad count lower  ok
        pad count type abcd ok

        $" ab/cd" count upper  ok
        pad count upper pad count type AB/CD ok

--
Julian V. Noble
Professor of Physics

Galileo's Commandment:

   "Science knows only one commandment: contribute to science."
   -- Bertolt Brecht, "Galileo".



Fri, 12 Mar 2004 00:01:43 GMT  
 Change of case



Quote:
> The Win32Forth words UPPER and LOWER are very useful,

    These words should be called UPPERCASE and LOWERCASE.

--

-GJC

-Abolish Public Schools.



Fri, 12 Mar 2004 01:24:30 GMT  
 Change of case

Quote:

> The Win32Forth words UPPER and LOWER are very useful,
> and presumably some or all of their functionality is
> included in any ANS system. There are no Standardized
> word names or Standardized behaviors for accomplishing
> this, but shouldn't there be? In order to assure the
> portability of ftranxxx I had to implement them, but
> would have vastly preferred to use the system words,
> if I knew what they were.

> \ example of UPPER and LOWER in action

> : $"      [CHAR] "  text  ;    \ use as $" abcd"  ok

>         $" abcd"  ok.
>         count type abcd ok
>         pad count upper  ok
>         pad count type ABCD ok
>         pad count lower  ok
>         pad count type abcd ok

>         $" ab/cd" count upper  ok
>         pad count upper pad count type AB/CD ok

> --
> Julian V. Noble
> Professor of Physics

> Galileo's Commandment:

>    "Science knows only one commandment: contribute to science."
>    -- Bertolt Brecht, "Galileo".

I've occasionally done something similar, and when I want the whole
string affected, use '' pad count 2dup upper type ''. Once, on a
case-sensitive system I defined "TYPE" as 2dup upper type , and "type"
as 2dup lower type , just to show off some Forth calisthenics.

I came to prefer versions of "type" that would translate the case
without modifying the original, allowing them to work on strings in ROM
without moving them to pad. That's one reason I prefer TYPE's relying on
EMIT , rather than the other way around.

Does any of this make sense?

Jerry
--
Engineering is the art of making what you want from things you can get.
-----------------------------------------------------------------------



Fri, 12 Mar 2004 02:04:15 GMT  
 Change of case

Quote:



> > The Win32Forth words UPPER and LOWER are very useful,

>     These words should be called UPPERCASE and LOWERCASE.

1. These ( addr len -- ) words should be.

2. The words ( c -- c ) also should be.

3. When both are there, I can never remember what is called what.

upc, upper, upperc, uppercase, s$uppercase...
lwc, lowc, lower, lowerc, lowercase, s$lowercase...

In addition, in most cases you do not want to modify the original text.

: foo S" foo" ;
foo upper type \ ????

char " parse abcdef" upper type \ ?????

Equally, you do not want to copy all into a buffer...
Nor to use a string package where it is unnecessary.

So UPPER ( addr len -- ) and LOWER ( addr len -- ) do
not resolve the problem in the general case.



Fri, 12 Mar 2004 03:07:42 GMT  
 Change of case


Quote:
> The Win32Forth words UPPER and LOWER are very useful,
> and presumably some or all of their functionality is
> included in any ANS system. There are no Standardized
> word names or Standardized behaviors for accomplishing
> this, but shouldn't there be? In order to assure the
> portability of ftranxxx I had to implement them, but
> would have vastly preferred to use the system words,
> if I knew what they were.

This is a problem that I faced.  The trouble with UPPER and LOWER
particularly UPPER is that there is no consistency.  Some systems
use UPPER to convert a string, and some use it to convert a
character.  Reading others' code I can't be sure.

So I have CHAR>UPPER and STRING>UPPER where there is no doubt.

(
--  

)



Fri, 12 Mar 2004 07:03:56 GMT  
 Change of case

Quote:



> > The Win32Forth words UPPER and LOWER are very useful,
> > and presumably some or all of their functionality is
> > included in any ANS system. There are no Standardized
> > word names or Standardized behaviors for accomplishing
> > this, but shouldn't there be? In order to assure the
> > portability of ftranxxx I had to implement them, but
> > would have vastly preferred to use the system words,
> > if I knew what they were.

> This is a problem that I faced.  The trouble with UPPER and LOWER
> particularly UPPER is that there is no consistency.  Some systems
> use UPPER to convert a string, and some use it to convert a
> character.  Reading others' code I can't be sure.

> So I have CHAR>UPPER and STRING>UPPER where there is no doubt.

> (
> --

> )

Quite right, there is no consistency. I guess I am asking if
there is any general interest in choosing a consistent set
of names/behaviors. The Forth Vendors' Group promulgated a
floating point standard in 1984 (DDJ) which was so helpful
to portability that it was taken over and incorporated into
ANS Forth 10 years later. IMO standardization is good for
common functions that are in most systems anyway.

--
Julian V. Noble
Professor of Physics

Galileo's Commandment:

   "Science knows only one commandment: contribute to science."
   -- Bertolt Brecht, "Galileo".



Fri, 12 Mar 2004 22:45:46 GMT  
 Change of case


Quote:
> Quite right, there is no consistency. I guess I am asking if
> there is any general interest in choosing a consistent set
> of names/behaviors. The Forth Vendors' Group promulgated a
> floating point standard in 1984 (DDJ) which was so helpful
> to portability that it was taken over and incorporated into
> ANS Forth 10 years later. IMO standardization is good for
> common functions that are in most systems anyway.

The inconsistent use of UPPER rules it out - it would break someone's
code.

The following are the words I regularly use:

    IS-WHITE   IS-DIGIT   IS-ALPHA   IS-ALNUM   IS-UPPER   IS-LOWER

    STRING>CI   STRING>UPPER   STRING>LOWER   STRING>HEADING

    CHAR>CI   CHAR>UPPER   CHAR>LOWER

    COMPARE-CI   SEARCH-CI

"CI" is for "case insensitive" and is adopted from HTML specs.
SwiftForth has COMPARE(NC) and MPE has ICOMPARE for COMPARE-CI.

CI is based on 8-bit Latin-1, not 7-bit Ascii.

--  



Sat, 13 Mar 2004 01:56:29 GMT  
 Change of case

Quote:
> The following are the words I regularly use:

>     IS-WHITE   IS-DIGIT   IS-ALPHA   IS-ALNUM   IS-UPPER   IS-LOWER

I'm curious why not the more Forth-like "digit?", for example.

James

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



Sat, 13 Mar 2004 04:44:51 GMT  
 Change of case

Quote:

>> The following are the words I regularly use:

>> IS-WHITE   IS-DIGIT   IS-ALPHA   IS-ALNUM   IS-UPPER   IS-LOWER

> I'm curious why not the more Forth-like "digit?", for example.

These names were adopted from SwiftForth several years ago, but more
important, words ending in "?" (except maybe "ENVIRONMENT?") are status
inquiries to me.

There is nothing in "DIGIT?" or "UPPER?" that suggests its arguments.



In my use, words ending in "?" tend not to change the stack.

(Exception:  "CASE?" which is equivalent to "OVER =  DUP IF  NIP  THEN".)

--  



Sat, 13 Mar 2004 07:28:48 GMT  
 Change of case


Quote:
>The following are the words I regularly use:
>    IS-WHITE   IS-DIGIT   IS-ALPHA   IS-ALNUM   IS-UPPER   IS-LOWER
>    STRING>CI   STRING>UPPER   STRING>LOWER   STRING>HEADING
>    CHAR>CI   CHAR>UPPER   CHAR>LOWER

For a standard, CHAR>UPPER STRING>UPPER is probably as compact as you
can get without breaking much code.  I personally would be in the

: UPPER ( c -- c' ) CHAR>UPPER ;

camp, since its more general in situations where you shouldn't or
can't modify the string source.
(
----------
Virtually,

Bruce McFarling, Newcastle,

)



Sat, 13 Mar 2004 07:39:33 GMT  
 Change of case

Quote:

> In my use, words ending in "?" tend not to change the stack.

> (Exception:  "CASE?" which is equivalent to "OVER =  DUP IF  NIP  THEN".)

How do you use CASE? ?


Sat, 13 Mar 2004 15:30:37 GMT  
 Change of case

Quote:

> > The following are the words I regularly use:

> >     IS-WHITE   IS-DIGIT   IS-ALPHA   IS-ALNUM   IS-UPPER   IS-LOWER

> I'm curious why not the more Forth-like "digit?", for example.

As to DIGIT? , this name is used in number conversion
and is BASE-dependent (at least in some Forths).


Sat, 13 Mar 2004 15:37:03 GMT  
 
 [ 23 post ]  Go to page: [1] [2]

 Relevant Pages 

1. changing the case but only the first char

2. POLL: Changing error cases in Tcl 8.4

3. Changing structure(case, while loop, etc.) border colors.

4. Upper case / Lower case I'm a lost case

5. CASE vs case vs Case...

6. Something else for a change / Parallel Computer for APL - in case you didn't know

7. select line by regexp/change Upper to Lower case

8. Using awk to change case in Script

9. Change Case on Record

10. How to change the type of Case selector

11. Changing an output box in a case structure to an input box

12. Input changes case - HELP!

 

 
Powered by phpBB® Forum Software