Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Finding joy in coding Using Pascal programming language


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
44 replies to this topic

#41 Tribad   Members   -  Reputation: 887

Posted 02 July 2013 - 03:46 AM

PASCAL writeln() procedure uses variable argument lists.



Sponsor:

#42 Paradigm Shifter   Crossbones+   -  Reputation: 5442

Posted 02 July 2013 - 03:54 AM

Presumably it must use a C-style calling convention for that then? (Another possibility is that the number/size of arguments is passed as a hidden parameter so that the called function can clean up the stack rather than the callee). EDIT: I'd have to look at the disassembly of the call to see what is going on in that case.

 

Anyway, that's the difference between pascal and C calling conventions (apart from the left to right parameter passing, again, it is easier to pass right to left if you use variable length argument lists, since the first argument is always bottom of the stack frame), and the reason for use in Win32 API was originally to save memory.


Edited by Paradigm Shifter, 02 July 2013 - 04:07 AM.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#43 mdwh   Members   -  Reputation: 901

Posted 08 July 2013 - 07:08 AM

There is no such language as C/C++ - yes, I know this point is sometimes pedantic, but it's important to distinguish when discussing something like pointers.

Can the OP clarify what he means by passing by value? I mean, passing strings and SDL_Surfaces by value would have the problem in C of copying large amounts of data - that's why C uses pointers.

C++ can do this by references - are you arguing against references and pointers? It can also handle this by copy-on-write, so passing by value doesn't necessarily copy data until required, but it's up to the classes/library to implement this.

How does Pascal pass information like strings around, or information to external libraries?

The SDL and WinAPI examples are C interfaces, not C++ ones. I guess it is a valid complaint that people often don't bother to write C++ interfaces, so you're still forced to deal with C-style interfaces and pointers in C++, but then I thought that it's harder to find out-of-the-box support for Pascal too? What do the same APIs for Pascal look like?

For the Qt example, the strings are passed by reference.


http://erebusrpg.sourceforge.net/ - Erebus, Open Source RPG for Windows/Linux/Android
http://homepage.ntlworld.com/mark.harman/conquests.html - Conquests, Open Source Civ-like Game for Windows/Linux

#44 Tribad   Members   -  Reputation: 887

Posted 08 July 2013 - 01:05 PM

Pass parameters by reference as C++ mention is a language construct. But normaly is implemented with pointers. Pointers are references too.

Niklaus Wirth, the founder of PASCAL, defined the two possibilities to pass parameter by value, logicaly copying them onto the stack, or passing them by reference. He uses these two mechanisms for to (dis-)allow a function/procedure to change the passed parameters on the callers side. This behaviour of passing parameters by reference and this way makeing the changes to the parameter within a function/procedure visible to the caller has introduced the "side-effect".

Using pointers and their description as something that describe the location where the value resides makes it easier to understand side-effects. For the C-Language using pointers was the only way of change a value within  a function and make it visible to the caller.

 

C++ introduced the reference with the same meaning and implementation but with the benefit not to stumble upon pointer arithmetics or with very unclean access to arrays of elements where only a single parameter was passed.

 

I do understand the reference in C++ but mostly use pointers because I am very familiar with that concept and always think in pointers.

 

AFAIK ANSI PASCAL has no modules concept. All code is put into a single file. And so you need no external libraries. Passing a string by value means copying to the stack. Needs a bit room on it.



#45 jms bc   Members   -  Reputation: 445

Posted 08 July 2013 - 04:07 PM

I know some grey hairs that still use Delphi 7.

 

A few years ago you might envy the built-in extended real data type (10 bytes), and the progs always seemed to run faster than what you could get from msvc with similar effort. 


The Four Horsemen of Happiness have left.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS