Recent

Author Topic: functions in pascal  (Read 9316 times)

balazsszekely

  • Guest
Re: functions in pascal
« Reply #15 on: March 13, 2021, 10:48:06 am »
@italyrobert
Quote
The static type array declaration in pascal, as I understand make it not possible to implement certain functions and I'm looking for an simple example of a function like that, but it should instead be possible to implement in C# instead,.
OK, understood. I'm certain that everything you can implement in c#, it can be done in pascal too. You may argue that the c# implementation is more elegant or perhaps easier, but don't forget that c# was developed by Anders Hejlsberg and his team with the knowledge accumulated developing object pascal. On the other hand, some may argue that  c#'s more modern features are overrated.
So what is the c# code that can't be implemented in pascal? I did work with c# in the past, but I cannot recall any magical feature of arrays.

PS: @MarkMLI was faster.

italyrobert

  • New member
  • *
  • Posts: 7
Re: functions in pascal
« Reply #16 on: March 14, 2021, 10:12:08 am »
@italyrobert
Quote
The static type array declaration in pascal, as I understand make it not possible to implement certain functions and I'm looking for an simple example of a function like that, but it should instead be possible to implement in C# instead,.
OK, understood. I'm certain that everything you can implement in c#, it can be done in pascal too. You may argue that the c# implementation is more elegant or perhaps easier, but don't forget that c# was developed by Anders Hejlsberg and his team with the knowledge accumulated developing object pascal. On the other hand, some may argue that  c#'s more modern features are overrated.
So what is the c# code that can't be implemented in pascal? I did work with c# in the past, but I cannot recall any magical feature of arrays.

PS: @MarkMLI was faster.

True, but perhaps the fixet array-size or type of array that could make it impossible for some functions to be implemented in pascal. It is an example of a function with that specific rule that dosnt work I'm looking for, and then it should work in C# instead.

WooBean

  • Full Member
  • ***
  • Posts: 230
Re: functions in pascal
« Reply #17 on: March 14, 2021, 10:44:35 am »
Hi italyrobert,
you had 6 opportunities to ask for assistance to your problem from this forum but you have missed  do it in a proper way.
It seems to me that somebody told/wrote to you that "for sure" c#-language syntacs is more advanced than pascal-language for defininig some functions with using static arrays (as parameters I guess).
If so, you can tell/write that somebody is wrong - pascal syntacs is wider - allows using static arrays (not only 0-based index) and dynamic arrays. In c#, as I remeber, arrays are always 0-based indexed.
See here for start:

https://www.freepascal.org/docs-html/ref/refsu14.html#x38-490003.3.1

WooBean

Platforms: Win7/64, Linux Mint Ulyssa/64

balazsszekely

  • Guest
Re: functions in pascal
« Reply #18 on: March 14, 2021, 11:24:34 am »
@WooBean
Quote
you had 6 opportunities to ask for assistance to your problem from this forum but you have missed  do it in a proper way.
I don't think he is looking for assistance. More likely he is a c# developer and got into one of those tiresome flame wars about which programming languages is better. Now he must prove to his friend that c#'s array implementation is better then pascal. I'm I right @Robert? :)

The bottom line is each language has pros and cons...Flame wars are useless.
« Last Edit: March 14, 2021, 11:26:57 am by GetMem »

cdbc

  • Hero Member
  • *****
  • Posts: 1083
    • http://www.cdbc.dk
Re: functions in pascal
« Reply #19 on: March 14, 2021, 01:48:00 pm »
Hi
Ok here goes:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/arrays/single-dimensional-arrays
Now run along and play nice with the other kids  ;)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: functions in pascal
« Reply #20 on: March 14, 2021, 01:57:58 pm »
I can't really think of anything, though I only did C# for a relative short time.

The only thing is maybe more seemless boxing from static arrays to dynamic arrays ?

But FPC has open arrays to still allow code to accept variable arrays of both types, so only the mechanism is different.

I think you should go back to your original source that said something couldn't be done in Pascal, and get examples.
« Last Edit: March 14, 2021, 02:46:26 pm by marcov »

avk

  • Hero Member
  • *****
  • Posts: 752
Re: functions in pascal
« Reply #21 on: March 14, 2021, 02:32:38 pm »
I recall something like Kernighan's passages on Why Pascal is not my favorite programming language.
Looks like the guy has been stuck somewhere for the last 40 years.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: functions in pascal
« Reply #22 on: March 14, 2021, 03:21:48 pm »
I recall something like Kernighan's passages on Why Pascal is not my favorite programming language.
Looks like the guy has been stuck somewhere for the last 40 years.

Didn't stop him from making a few bucks out of it. However since his book was written in 1976 he was obviously considering a pre-Turbo implementation of the language.

However I would caution that "the language has improved over the last 40 years" is not a fair statement. COBOL and FORTRAN are said by their devotees to be cutting edge because they have had e.g. "object orientation" grafted onto them... an exercise akin to putting lipstick on a pig since we all know what swines the underlying languages were. Pascal OTOH, even as originally defined, has been remarkably influential with almost every successor language at least acknowledging the ideas that it introduced: records, strong typing and so on.

But I still say that this thread's OP is asking his question in the wrong place.

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

avk

  • Hero Member
  • *****
  • Posts: 752
Re: functions in pascal
« Reply #23 on: March 14, 2021, 04:10:19 pm »
Quote

  ...However since his book was written in 1976..
  It looks like it was in 1981.
Here it is:
Quote
2.1.  The size of an array is part of its type

If one declares
     var     arr10 : array [1..10] of integer;
             arr20 : array [1..20] of integer;
...
...
This botch is the biggest single problem with Pascal...
Curiously, some of his complaints were already irrelevant at the time of publication.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: functions in pascal
« Reply #24 on: March 14, 2021, 04:34:05 pm »
This says it all:

Quote
The size of an array is part of its type

The point there is that an array is a type, and that type is checked. Unlike classic C, where there are primitive types and unchecked arrays.

Now if he'd explicitly said "no provision for open array parameters" or "no provision for extensible arrays" then he would have deserved a bit more sympathy. But complaining that arrays have a type simply indicates that he didn't really understand what he was writing about.

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

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: functions in pascal
« Reply #25 on: March 18, 2021, 12:46:05 pm »
I don't think he is looking for assistance. More likely he is a c# developer and got into one of those tiresome flame wars about which programming languages is better. Now he must prove to his friend that c#'s array implementation is better then pascal. I'm I right @Robert? :)
I can smell that, too ;)
Sadly, he will only get the other way around as Pascal arrays are a hell lot more flexible than C#. The best that C# can match is declaring arrays on stack using the stackalloc reserved word, but declaring different bounds is only a dream.

italyrobert

  • New member
  • *
  • Posts: 7
Re: functions in pascal
« Reply #26 on: March 21, 2021, 02:37:56 pm »
Quote

  ...However since his book was written in 1976..
  It looks like it was in 1981.
Here it is:
Quote
2.1.  The size of an array is part of its type

If one declares
     var     arr10 : array [1..10] of integer;
             arr20 : array [1..20] of integer;
...
...
This botch is the biggest single problem with Pascal...
Curiously, some of his complaints were already irrelevant at the time of publication.

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#?

That's my question. Seems like ther's some misunderstandings going around here

avk

  • Hero Member
  • *****
  • Posts: 752
Re: functions in pascal
« Reply #27 on: March 21, 2021, 03:14:36 pm »
It seems I got it right. :)
This "biggest" problem hasn't exists for 40 years. Therefore, I have a different proposal.
When you find the example you want, do a favor and share it with others.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: functions in pascal
« Reply #28 on: March 21, 2021, 03:24:34 pm »
That's my question. Seems like ther's some misunderstandings going around here

No, there are no misunderstandings at all. Find an example which you believe or have told can't be implemented in current Pascal dialects, and post it here for discussion.

It's YOUR responsibility to do that. And it's YOUR privilege, since asking a bunch of people committed to Pascal to point out flaws in it is not likely to get you a useful response.

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

PascalDragon

  • Hero Member
  • *****
  • Posts: 5481
  • Compiler Developer
Re: functions in pascal
« Reply #29 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.

 

TinyPortal © 2005-2018