Recent

Author Topic: Has anyone converted the C librarys to FreePascal?  (Read 6668 times)

del

  • Full Member
  • ***
  • Posts: 180
Re: Has anyone converted the C librarys to FreePascal?
« Reply #15 on: September 26, 2019, 01:59:01 am »
I would like to add: You also need a compiler which help you to improve and is "your friend" and don't let you make silly mistakes or screw every thing up because of a wrong -type assignment.

Besides, C has the most shitty syntax you can find among the popular languages.

Well ... I can't complain about Pascal. It spoiled me with its nested functions. So I use lambdas to get the same effect in C++. However, it would be nice if Pascal and its compilers enforced case sensitivity with variable, function, and type names. Code can look pretty ratty if the same entity shows up in a bazillion different forms, and the loose namespace can surprisingly take you to all kinds of unanticipated places.

jamie

  • Hero Member
  • *****
  • Posts: 2495
Re: Has anyone converted the C librarys to FreePascal?
« Reply #16 on: September 26, 2019, 02:02:55 am »
Oh please don't do that, that is one of the things that takes me hours to debug having same names with different cases...

 If I make a mistake with a Case in Pascal I don't need to worry bout it not compiling or it calling the wrong identifier.
Number 1 at blue screen app creations!

Thaddy

  • Hero Member
  • *****
  • Posts: 9809
Re: Has anyone converted the C librarys to FreePascal?
« Reply #17 on: September 26, 2019, 08:27:50 am »
I fully agree.  Case insensitivity is one very productive feature of Pascal over C/C++ and other curly bracket languages.
+10
Code: C  [Select]
  1. /* wanna get nuts?  valid code... */
  2. int ieee;
  3. int Ieee;
  4. int ieeE;
  5. int iEee;
  6. int IEEe;
  7. /* even... */
  8. int INT;
« Last Edit: September 26, 2019, 08:40:24 am by Thaddy »
I am more like donkey than shrek

PascalDragon

  • Hero Member
  • *****
  • Posts: 1112
  • Compiler Developer
Re: Has anyone converted the C librarys to FreePascal?
« Reply #18 on: September 26, 2019, 09:02:50 am »
(Though just to stay on topic, I still say the C librarys in FreePascal would be rather cool / handy and did get a little excited about it when I had the idea. >.>
...Also, so far, 6hrs till I can get towed. OMG x.x)
I don't get why you're so fixated on C libraries. If you want him to learn concepts of programming with Free Pascal than you don't need to resort to C libraries at all. And once he has some understanding of the basics he can find libraries himself if needed.

I recommend learning C in order to get a clear understanding of memory management. Then you can make your own simple classes that manage their own memory and that takes away 99% of the hassle. Compile it of course as C++. But you're still down in the weeds. You'll get an appreciation of what happens in constructors and destructors. Then you can jump around between C++ and Free Pascal and see what you like and etc. I would also stay away from Python - you'll just pick up so much mush that you'll have to unlearn later IMHO.
The same basics regarding memory management can be learned with FPC as well.

RayoGlauco

  • Full Member
  • ***
  • Posts: 100
  • Beers: 1567
Re: Has anyone converted the C librarys to FreePascal?
« Reply #19 on: September 26, 2019, 11:06:59 am »
Well ... I can't complain about Pascal. It spoiled me with its nested functions. So I use lambdas to get the same effect in C++. However, it would be nice if Pascal and its compilers enforced case sensitivity with variable, function, and type names. Code can look pretty ratty if the same entity shows up in a bazillion different forms, and the loose namespace can surprisingly take you to all kinds of unanticipated places.

Visual Basic editor has a feature I do like: when you type an identifier, it gets converted to the case of its declaration. I think this may be good for the Lazarus editor (i.e.: if you declare MyVariable:integer and then you write MYVARIABLE := 2; then it is automatically changed to MyVariable := 2; .
To err is human, but to really mess things up, you need a computer.

howardpc

  • Hero Member
  • *****
  • Posts: 3359
Re: Has anyone converted the C librarys to FreePascal?
« Reply #20 on: September 26, 2019, 02:09:54 pm »
The Lazarus editor already has this capability.
If you declare
Code: Pascal  [Select]
  1. MyVar: Integer;
and then type myv followed by Ctrl-Space, the name is filled in with the capitalisation from its declaration.
It is not (yet) automatic, i.e. it does need you to press Ctrl-Space.
« Last Edit: September 26, 2019, 02:12:11 pm by howardpc »

garlar27

  • Hero Member
  • *****
  • Posts: 635
Re: Has anyone converted the C librarys to FreePascal?
« Reply #21 on: September 26, 2019, 05:45:01 pm »
It can't be that bad since fpc has adopted some of it.

+=,. -= *= etc..

 I kind of wish it would adopt a few other things from C but you can't have it all I guess.

 Like for example a compound assignment and Boolean test..

Code: Pascal  [Select]
  1.  If (SomeVar := AFunction(ParamsIfNeede)) = ? then
  2.  
An Assignment and Testing the results in a short line.
See the beauty in that  :D
It looks awful for me...
That's one of the many problems with C syntax

It may be "nice" when coding but not when debugging or during maintenance...

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8103
Re: Has anyone converted the C librarys to FreePascal?
« Reply #22 on: September 26, 2019, 05:54:35 pm »
It can't be that bad since fpc has adopted some of it.

+=,. -= *= etc..

FPC hasn't adopted those. They are only supported for conversion purposes, and were never intended to be used in newly written pascal code.
 

Thaddy

  • Hero Member
  • *****
  • Posts: 9809
Re: Has anyone converted the C librarys to FreePascal?
« Reply #23 on: September 26, 2019, 05:56:36 pm »
Question marks are an integral part of the C language,,,,, This is legal:
Code: C  [Select]
  1. const int n = (x != 0) ? 10 : 20;
Does it have logic? (note const..)
« Last Edit: September 26, 2019, 06:03:34 pm by Thaddy »
I am more like donkey than shrek

Thaddy

  • Hero Member
  • *****
  • Posts: 9809
Re: Has anyone converted the C librarys to FreePascal?
« Reply #24 on: September 26, 2019, 05:59:33 pm »
It can't be that bad since fpc has adopted some of it.

+=,. -= *= etc..

FPC hasn't adopted those. They are only supported for conversion purposes, and were never intended to be used in newly written pascal code.
To that I agree, but why never marked such use as deprecated... I once asked for =+ (first assign, then increment =++ as opposed to ++= )etc... which was refused. I think {$coperators on} should be - well - deprecated.
They are not complete and misleading.
On occasion I also misuse the feature, though.
« Last Edit: September 26, 2019, 06:05:22 pm by Thaddy »
I am more like donkey than shrek

howardpc

  • Hero Member
  • *****
  • Posts: 3359
Re: Has anyone converted the C librarys to FreePascal?
« Reply #25 on: September 26, 2019, 06:14:07 pm »
It can't be that bad since fpc has adopted some of it.

+=,. -= *= etc..

FPC hasn't adopted those. They are only supported for conversion purposes, and were never intended to be used in newly written pascal code.
If that is really the case, how do you account for the 33,403 occurrences of += counted today in a trawl of recent FPC sources (never mind use of Cisms in the LCL)?

winni

  • Hero Member
  • *****
  • Posts: 1146
Re: Has anyone converted the C librarys to FreePascal?
« Reply #26 on: September 26, 2019, 07:15:13 pm »
The very most of the  33,403 occurrences of += are in the makefiles. This is not Pascal. Did you know???? And some are in some quick-and-dirty testfiles.

That is the truth.

Thaddy

  • Hero Member
  • *****
  • Posts: 9809
Re: Has anyone converted the C librarys to FreePascal?
« Reply #27 on: September 26, 2019, 07:22:54 pm »
Of course he knows.
I am more like donkey than shrek

howardpc

  • Hero Member
  • *****
  • Posts: 3359
Re: Has anyone converted the C librarys to FreePascal?
« Reply #28 on: September 26, 2019, 07:57:41 pm »
The very most of the  33,403 occurrences of += are in the makefiles. This is not Pascal. Did you know???? And some are in some quick-and-dirty testfiles.

That is the truth.
The 33,403 figure comes from counting "+=" in *.pas, *.inc, *.pp in directories under fpcsrc.
Are any of those makefiles?

winni

  • Hero Member
  • *****
  • Posts: 1146
Re: Has anyone converted the C librarys to FreePascal?
« Reply #29 on: September 26, 2019, 08:07:29 pm »
Yes - do you think I'm dump? From a lot of subdirectories which all contain makefiles.

Do you want to see the whole output of grep? I think it does not fit in the 250k limit for attachments.

I can't stand those Donald-Trump-Boris-Johnson-News!

Winni