Solved

4 things C can do that Pascal canot

Posted on 1998-09-25
10
253 Views
Last Modified: 2010-04-15
Name 4 things that can be done in C that cannot be done (easily) in Pascal.
0
Comment
Question by:morgan1
10 Comments
 
LVL 8

Expert Comment

by:Answers2000
ID: 1253047
Which Pascal ?

Turbo Pascal / Delphi - have a lot of language extensions to support C/C++ concepts
0
 
LVL 2

Accepted Solution

by:
JYoungman earned 200 total points
ID: 1253048
1 longjmp().
2 Pass arbitrary-length arrays to a subroutine.
3 Change the buffering mode of stdin/out
4 Handle signals
5 Separate compilation (this is only a criticism of old or          standard-conforming implementations).


0
 

Author Comment

by:morgan1
ID: 1253049
What is meant by handle signals?
0
 
LVL 11

Expert Comment

by:alexo
ID: 1253050
#1, #3 and #4 are not the C language per se but the standard library.

* Due to the calling convention used by Pascal, it cannot pass a variable number of arguments to a function (e.g., printf).

* Casting (especially pointer types).
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1253051
alexo,
* pascal can pass variable number of arguments: writeln()
  (but it's limited to pascal-known functions)
* casting cannot be done, but you may use variant records
  (which results in the same as casting)

What cannot be done in pascal:
  - getting addresses (C's  &  operator)
  - pointer to functions
  - operators:  ++  --  [=-/*]=
  - variable definition/declaration in blocks
  - declaring arrays of undefined length



0
Save on storage to protect fatherhood memories

You're the dad who has everything. This Father's Day, make sure your family memories are protected. My Passport Ultra has automatic backup and password protection to keep your cherished photos and videos safe. With up to 3TB, you have plenty of room to hold the adventures ahead.

 
LVL 8

Expert Comment

by:Answers2000
ID: 1253052
In Delphi/Turbo you can do quite a lot of the supposedly impossible things listed previously.

But Of course that's not "standard" Pascal

0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253053
In Delphi and Turbo Pascal, you can create a function that accepts a variable number of parameters of varying types.  In Delphi you would declare a function with one formal parameter, like this:

procedure x (const y :array of const)

and use the VType field of TVarRec to check each variable's type.
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253054
Alexo:

  "- getting addresses (C's  &  operator)
  - pointer to functions  "

  Is the @ operator available in ANSI Pascal, or is it a Turbo Pascal specific operator?


0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253055
In Delphi and Turbo Pascal, you can create a function that accepts a variable number of parameters of varying types.  In Delphi you would declare a function with one formal parameter, like this:

procedure x (const y :array of const)

and use the VType field of TVarRec to check each variable's type.
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253056
Please excuse me for posting twice, it was an accident
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now