Recent

Author Topic: functions in pascal  (Read 5812 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 3059
  • Compiler Developer
Re: functions in pascal
« Reply #30 on: March 22, 2021, 09:26:12 am »
So with this being the biggest problem, is there any functions, LIKE ANY EXAMPLE, which can't be implemented in pascal because of this. but instead C#?

There is no because of this, because modern Pascal is not restricted to this as everyone else already wrote. In the Pascal of the past (30, 40 years ago) there would be functions that can't be (easily) implemented, but since the era of Delphi (mid 90s) at the latest this is not the case anymore.

Rinzwind

  • Newbie
  • Posts: 2
Re: functions in pascal
« Reply #31 on: March 22, 2021, 11:39:01 am »
So far I know that arraytypes in Pascal is declared with an array length, but is there functions which might cannot be implemented because of that? and maybe still be written in C# for example?
No, there are not any functions that cannot be written because of that.
Clear?

BeniBela

  • Hero Member
  • *****
  • Posts: 793
    • homepage
Re: functions in pascal
« Reply #32 on: March 22, 2021, 02:26:08 pm »
So with this being the biggest problem, is there any functions, LIKE ANY EXAMPLE, which can't be implemented in pascal because of this. but instead C#?

There is no because of this, because modern Pascal is not restricted to this as everyone else already wrote. In the Pascal of the past (30, 40 years ago) there would be functions that can't be (easily) implemented, but since the era of Delphi (mid 90s) at the latest this is not the case anymore.

You cannot implement writeln(1.0:2:3) for your own types

MarkMLl

  • Hero Member
  • *****
  • Posts: 2700
Re: functions in pascal
« Reply #33 on: March 22, 2021, 03:10:14 pm »
You cannot implement writeln(1.0:2:3) for your own types

Can you extend the basic syntax in C# to handle things like that? In any event you can do WriteLn(1.0, [2, 3]) in Object Pascal which is /functionally/ equivalent... and OP wasn't asking for exactly the same syntax, just for examples of "things that couldn't be done").

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

lucamar

  • Hero Member
  • *****
  • Posts: 4009
Re: functions in pascal
« Reply #34 on: March 22, 2021, 03:32:49 pm »
In the Pascal of the past (30, 40 years ago) there would be functions that can't be (easily) implemented, but since the era of Delphi (mid 90s) at the latest this is not the case anymore.

This wasn't the case even way before Delphi: most Pascal compilers of the mid-80s (1982 the oldest I know about: Pascal MT+ v5) already allowed for this in one way or other.

The thing is that while valid for what he was talking about, Kerningham's critic was one of the last even remotely founded on fact, and even then most compiler producers had started to solve most of those shortcomings in one way or other.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2700
Re: functions in pascal
« Reply #35 on: March 22, 2021, 04:48:43 pm »
In the Pascal of the past (30, 40 years ago) there would be functions that can't be (easily) implemented, but since the era of Delphi (mid 90s) at the latest this is not the case anymore.

This wasn't the case even way before Delphi: most Pascal compilers of the mid-80s (1982 the oldest I know about: Pascal MT+ v5) already allowed for this in one way or other.

I never used newer than about v3. Or perhaps v2. And while I might have seen worse compilers it was everything expected from DR: I ended up having to rewrite the runtime library to save x87 state, and it obfuscated its .obj format by appending a rolling zero bit to each byte and packing the result.

Quote
The thing is that while valid for what he was talking about, Kerningham's critic was one of the last even remotely founded on fact, and even then most compiler producers had started to solve most of those shortcomings in one way or other.

The point about Write()-like functions taking multiple parameters and the colon-separated format specification is valid criticism of the early syntax, but the important fact is that there are alternative ways of achieving the same result from Delphi onwards.

However I'd throw in as a detail that Pascal was very much typical of early-70s compilers in that its predefined functions were handled by the compiler (so could have non-standard syntax) rather than there being a more general library mechanism.

Even if Kernighan's criticism was based on fact, it demonstrated that he didn't really /get/ the idea of type checking: a 10-element array is /not/ assignment-compatible with a 9-element array hence it is not compatible in the more general sense of being an interchangeable parameter.

Such things /can/ be a problem if using Pascal or its close relatives for systems programming (e.g. passing network packets around), but Kernighan wasn't claiming to do that so I feel his criticism was out of place.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

lucamar

  • Hero Member
  • *****
  • Posts: 4009
Re: functions in pascal
« Reply #36 on: March 22, 2021, 05:16:35 pm »
Such things /can/ be a problem if using Pascal or its close relatives for systems programming (e.g. passing network packets around), but Kernighan wasn't claiming to do that so I feel his criticism was out of place.

IMHO, one should read both editions of Software Tools to fully understand what Kerninghan was talking about. He was trying to translate some relatively complex things from Fortran to fairly "standard" Pascal (J&W's) and, logically enough, he found quite some problems.

It matters little nowadays, other than by ignorant people refering to an obsolete criticism to bash on modern Pascal and not remembering that Kerningham himself wrote a partial refutation to that paper later on, after seeing how the language had evolved (even though he said in it that he still preferred C :o)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

PascalDragon

  • Hero Member
  • *****
  • Posts: 3059
  • Compiler Developer
Re: functions in pascal
« Reply #37 on: March 23, 2021, 09:37:58 am »
So with this being the biggest problem, is there any functions, LIKE ANY EXAMPLE, which can't be implemented in pascal because of this. but instead C#?

There is no because of this, because modern Pascal is not restricted to this as everyone else already wrote. In the Pascal of the past (30, 40 years ago) there would be functions that can't be (easily) implemented, but since the era of Delphi (mid 90s) at the latest this is not the case anymore.

You cannot implement writeln(1.0:2:3) for your own types

That was not the question however. The question was related to array types and whether you can implement any C# function using such as result types in (modern) Pascal.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2700
Re: functions in pascal
« Reply #38 on: March 23, 2021, 09:57:00 am »
That was not the question however. The question was related to array types and whether you can implement any C# function using such as result types in (modern) Pascal.

And even if it had been the question there was no requirement that the syntax be identical, only that functionally equivalent code could be written.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

ASBzone

  • Hero Member
  • *****
  • Posts: 613
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: functions in pascal
« Reply #39 on: March 26, 2021, 05:15:38 am »

Did the planet have a lot of tainted water this month?   I've seen more crazy posts this month than I've seen in a long time...
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.0.13 r64843 / FPC v3.2.1-r49055 (via FpcUpDeluxe) -- Windows 64-bit install w/Win32 and Linux/Arm cross-compiles
Primary System: Windows 10 Pro x64, Version 2009 (Build 19042)
Other Systems: Windows 10 Pro x64, Version 2009 (Build 19042) or greater

dsiders

  • Sr. Member
  • ****
  • Posts: 464
Re: functions in pascal
« Reply #40 on: March 26, 2021, 06:00:00 am »

Did the planet have a lot of tainted water this month?   I've seen more crazy posts this month than I've seen in a long time...

Pandemic psychosis.
Lazarus 2.0.12, 2.3 (SVN) / FPC 3.2.0, 3.2.2 / x86-win64 / Windows 8.1

Brizeux

  • New Member
  • *
  • Posts: 22
Re: functions in pascal
« Reply #41 on: March 26, 2021, 09:49:02 am »
A beginner question on functions in FPC pascal : I want to use ArcSin, ArcCos and ArcTan2 of unit math ; is it possible to have access to the ArcTan2.pas source instead of ArcTan2.ppu, to carefully study the implementation of mathematical functions in my code ? because the recipe for, for instance x+iy complex is to use t := 2*ArcTan2( y, x+Sqrt( x*x+y*y ) on the range ]-Pi..Pi] for
the complex logarithm/exponential pseudo-functions. (I shal be glad to incorporate modifications of this function in my code for
mathematical accuracy).  Friendly. Yves .

winni

  • Hero Member
  • *****
  • Posts: 2406
Re: functions in pascal
« Reply #42 on: March 26, 2021, 10:16:50 am »
A beginner question on functions in FPC pascal : I want to use ArcSin, ArcCos and ArcTan2 of unit math ; is it possible to have access to the ArcTan2.pas source instead of ArcTan2.ppu, to carefully study the implementation of mathematical functions in my code ? because the recipe for, for instance x+iy complex is to use t := 2*ArcTan2( y, x+Sqrt( x*x+y*y ) on the range ]-Pi..Pi] for
the complex logarithm/exponential pseudo-functions. (I shal be glad to incorporate modifications of this function in my code for
mathematical accuracy).  Friendly. Yves .

Hi!

Place your cursor on ArcTan2.
Press Alt + CursorUp.

There you are.

Winni

MarkMLl

  • Hero Member
  • *****
  • Posts: 2700
Re: functions in pascal
« Reply #43 on: March 26, 2021, 10:25:30 am »
A beginner question on functions in FPC pascal : I want to use ArcSin, ArcCos and ArcTan2 of unit math ; is it possible to have access to the ArcTan2.pas source instead of ArcTan2.ppu, to carefully study the implementation of mathematical functions in my code ? because the recipe for, for instance x+iy complex is to use t := 2*ArcTan2( y, x+Sqrt( x*x+y*y ) on the range ]-Pi..Pi] for
the complex logarithm/exponential pseudo-functions. (I shal be glad to incorporate modifications of this function in my code for
mathematical accuracy).  Friendly. Yves .

Noting what @winni says, this will obviously require that you have the FPC sources installed and assumes that you are using Lazarus as an IDE.

Please note that it is considered very bad form to tack a fresh question onto somebody else's thread. In addition if you want a more detailed answer you should tell us what versions of FPC, Lazarus etc. you're running, and what OS you're using: that will save us having to guess.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Seenkao

  • Full Member
  • ***
  • Posts: 157
Re: functions in pascal
« Reply #44 on: March 26, 2021, 11:03:07 am »
Не решаемых проблем нет. Есть проблемы, на которые надо потратить больше времени!

Eng: There are no unsolvable problems. There are problems that need to be spent more time!

 

TinyPortal © 2005-2018