Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Trigraphs & entry

Reply
Thread Tools

Trigraphs & entry

 
 
Mark McIntyre
Guest
Posts: n/a
 
      11-05-2003
On Tue, 4 Nov 2003 09:52:03 +0530, in comp.lang.c , "Vijay Kumar R
Zanvar" <(E-Mail Removed)> wrote:

>I have following questions:
>
> 1. Appendix C of K&R says:
> Trigraph sequences introduced by ?? allow
> representation of characters lacking in some
> character sets. ...
>
> Can somebody explain how trigraphs are used?


in Days of Yore, some keyboards didn't have certain keys, such as hash
(#), or angles <>. To get round this, the C standard defined trigraphs
that you can use instead.

Bizarrely I've actually used these recently. On my power mac G3
keyboard I can never remember how to type the hash key, so I use the
trigraph ??= instead. (For the uninitiated, Beige G3s have the
sterling symbol on shift-3, and the / above the right-shift. Hash is
not on the menu).

I've also used them when typing on French keyboard layouts with UK
keyboards as its quicker than mollocking around trying to second-guess
zhere the blqsted hqsh key hqs vqnished to: Qnd donýt even get ,e
stqrted on the qngles::::
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
 
Reply With Quote
 
 
 
 
Giorgio Pastore
Guest
Posts: n/a
 
      11-05-2003
Sheldon Simms wrote:
....
> Just curious, but is this true of current italian keyboards, or
> just old ones?


> I, for example, use a german keyboard. All of the required characters
> are there, but many of them require using the "Alt Gr" key, from
> which I infer that older german keyboards simply did not have them.



Some have the square brackets (to be used wuth Alt Gr) but not the
curly ones and it would be possible to write C programs without arrays
but not without { }


Giorgio Pastore

 
Reply With Quote
 
 
 
 
Giorgio Pastore
Guest
Posts: n/a
 
      11-05-2003
Sheldon Simms wrote:
....
> Just curious, but is this true of current italian keyboards, or
> just old ones?
>
> I, for example, use a german keyboard. All of the required characters
> are there, but many of them require using the "Alt Gr" key, from
> which I infer that older german keyboards simply did not have them.


Some have the square brackets (to be used with Alt Gr) but in general
there is no curly bracket. Not a nice feature for C programmers ! And
even worse if you have to *teach* C.

Giorgio Pastore

 
Reply With Quote
 
Glen Herrmannsfeldt
Guest
Posts: n/a
 
      11-05-2003

"August Derleth" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> "Vijay Kumar R Zanvar" <(E-Mail Removed)> wrote in message

news:<bo79gc$1a1uu1$(E-Mail Removed)-berlin.de>...
>
> <snip>
>
> > 2. What `entry' keyword was used for?

> [off-topic]
>
> The entry keyword was intended to provide subroutines with more than
> one point of entry. That way, you could write one block of code and
> have it `stand in for' different subroutines, because different calls
> would deposit you to different places within the code.


In PL/I the ENTRY keyword is used for both multiple entry to procedures, and
also for declaring procedure names. In C the () pretty much identify a
function name so that the entry attribute is not needed. PL/I allows
functions without any argument list, so the ENTRY attribute is needed to
declare them.

The C declaration double sqrt(); in PL/I would be DCL SQRT ENTRY
RETURNS(FLOAT BINARY(53)); though RETURNS implies ENTRY in this case, so
the ENTRY attribute is really only needed when nothing is returned.

> The problem with this is obvious: It reduces subroutine calls to
> gotos, and it makes it difficult to predict exactly where the next
> step of the program would take you. It /could/ be used in structured
> code, but only with care. Besides that, it really offers nothing real
> subroutines don't.


Like many language features, it can be used for good or evil. The C file
scope variables reduce the need for it. One example in other languages
might be a random number generator and its initialization/seed call.
Another obvious example is the sin() and cos() entries to a routine that can
compute either of them. Multiple entry points are a little more memory and
time efficient in both cases, though faster computers have reduced the
importance of both.

> The concept was borrowed from FORTRAN and was part of very early
> designs of C. Apparently, some compiler designers did implement it,
> but I've never seen an implementation that actually used the entry
> keyword.


It is complicated in the case of functions, where different entry points
might have a different return type. When you have multiple entries into a
function, and the entries have a different return type, it greatly
complicates the return statement. In Fortrans that implement ENTRY,
functions return a value by assigning it to a variable named after the
function, so the compiler knows the type to convert it to. (All the names
are EQUIVALENCEd, somewhat similar to C's union, though they are required to
overlap in memory.) PL/I seems to have the ability to convert the type of
the return value to the type of any of the entry points. Possibly the
conversion requirement was enough to remove it from consideration for C.

> Really, it isn't a big loss. The concept of one subroutine with
> multiple entry points was on its way out even before C was new, and it
> was wise of the standards makers to ignore such a half-baked idea.


Another reason it isn't needed so much is the va_arg feature of C. In
languages that have multiple entry points, one use for them is to implement
different argument types or number of arguments. (Consider the atan() and
atan2() functions, though va_arg doesn't help much there.) The small number
of cases where it would be needed can be implemented by having functions
with the required arguments all call a common function. In those cases,
though, I would say that mulitple entries are more readable.

-- glen




 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      11-05-2003
On Wed, 05 Nov 2003 11:54:04 +0100, in comp.lang.c , Giorgio Pastore
<(E-Mail Removed)> wrote:

>Sheldon Simms wrote:
>...
>> Just curious, but is this true of current italian keyboards, or
>> just old ones?
>>
>> I, for example, use a german keyboard. All of the required characters
>> are there, but many of them require using the "Alt Gr" key, from
>> which I infer that older german keyboards simply did not have them.

>
>Some have the square brackets (to be used with Alt Gr) but in general
>there is no curly bracket. Not a nice feature for C programmers ! And
>even worse if you have to *teach* C.


You think that's bad? Try a greek or russian keyboard !!

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: trigraphs, yecch Keith Thompson C Programming 20 02-07-2012 10:40 AM
Re: trigraphs, yecch Ben Bacarisse C Programming 9 02-01-2012 01:27 PM
Re: trigraphs, yecch Peter Nilsson C Programming 7 02-01-2012 12:15 PM
Trigraphs Daniel Rudy C Programming 39 01-06-2006 04:22 PM
Trigraphs Christopher Benson-Manica C Programming 33 09-18-2003 12:39 AM



Advertisments