Recent

Author Topic: FreePascal made it to project of the month on Sourceforge  (Read 45684 times)

edwinyzh

  • New Member
  • *
  • Posts: 43
Re: FreePascal made it to project of the month on Sourceforge
« Reply #30 on: April 17, 2014, 09:35:35 pm »
so it's very clear to see what will happen after the js code returns a value, otherwise I'll have to define the call back in another method. 

The trouble is that that is a matter of personal preferences. I think it also complicates overviewing what a method does in one glance.
Well, if the callback is long than I agree with you that it's better to put the code as a separate method, but when the code is short I prefer to use a mechanism like Python's lambda (but support multiple line code blocks).

edwinyzh

  • New Member
  • *
  • Posts: 43
Re: FreePascal made it to project of the month on Sourceforge
« Reply #31 on: April 17, 2014, 09:51:12 pm »
Apart from the code cleanliness, another benefit that anonymous methods makes it easy to use local variables, this part I don't go further here, but it's also a great benefit.

Actually that is called a closure isn't it? And you do not need an anonymous method for a closure. You could use a nested named procedure instead, if closures were implemented (and if they were implemented using nested procs)
Well, as a matter of fact, I did mix the concept of a closure and anonymous method. And while actually what I want to most is closure.

As for your suggestion of implementing closure by adding a special modifier to nested functions, as I replied to @marcov above, it look like a better way of using closures, but in case of short callback code blocks, I think anonymous method implementation like Python's lambda (but support multiline of code blocks) is better, because the code logic is clearer (sequential and in one place).
Jut my two cents.

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 328
  • Love my Wife, My Kids and Lazarus/Freepascal.
Re: FreePascal made it to project of the month on Sourceforge
« Reply #32 on: April 18, 2014, 01:39:24 am »
Thanks Florian and the team for Freepascal and Lazarus.
Best regards
Robbanux
Rob

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: FreePascal made it to project of the month on Sourceforge
« Reply #33 on: April 18, 2014, 03:40:56 am »
Quote
We'll, that'll be too much of a hassle for an average to figure out how to use that FPC branch with the official Lazarus, while being uncertained and worried about it not including the latest bugfixes in the latest trunk.
It's not for average user yet, the reason why it's on separate branch. Average user should use stable, or trunk if required and only other branches if they want to improve it.
Quote
I don't believe that by providing anonymous methods will result in executable size increment to a level that overweighs the benefit of anonymous methods.
You never code it in a compiled language, don't you? Go on and try it yourself.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: FreePascal made it to project of the month on Sourceforge
« Reply #34 on: April 18, 2014, 10:35:39 am »
Closure vs anonymous method yes.  Nested proc vs closure/anonymous no. The nested proc passed as closure only has validity as long as the frame of its parent on the stack is intact.  Anonymous methods are afaik implemented as an under the hood interface that allocates dedicated space on the heap for what it captures in, and is freed when no longer need.

But that is a question of what what the compiler implements.

Passing nested functions with access to parent state are supported *now* :-)
Code: [Select]
{$modeswitch nestedprocvars}

 Type TMyCallback=procedure(Index:Integer) is nested;

Quote
Except for a "nested" procedure, that should be used as closure, may be named different. So the name "nested" may then be wrong. (and it would technically not be "nested" as it would not have all the properties that a current nested has /but it would be declared in a very similar way)

Yes, simply a not inline declared function is the best term I guess.

With a clean slate I would favor such development, but as usual I think Delphi compatibility should prevail.  That's better then ending up with two such constructs.


edwinyzh

  • New Member
  • *
  • Posts: 43
Re: FreePascal made it to project of the month on Sourceforge
« Reply #35 on: April 18, 2014, 10:54:54 am »
Quote
I don't believe that by providing anonymous methods will result in executable size increment to a level that overweighs the benefit of anonymous methods.
You never code it in a compiled language, don't you? Go on and try it yourself.
Actually, I use anonymous method in Delphi and I haven't noticed nor I heard that it results in significant exe size increment. On the other hand, Generics and enhanced RTTI in Delphi adds noticeable extra file size to the bin output.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: FreePascal made it to project of the month on Sourceforge
« Reply #36 on: April 18, 2014, 11:12:26 am »
Quote
Actually, I use anonymous method in Delphi and I haven't noticed nor I heard that it results in significant exe size increment.
Do you have a lot of anonymous methods with similar body? If not, then it's expected. Otherwise, Delphi compiler has found a good way to optimize that away better than Haskell compiler does (well, actually there's a difference in philosophy as well, where Haskell compiler tends to think "you can buy space, but not time" so they sacrifice size for speed).

motaz

  • Sr. Member
  • ****
  • Posts: 495
    • http://code.sd
Re: FreePascal made it to project of the month on Sourceforge
« Reply #37 on: April 18, 2014, 11:22:47 am »
Quote
        Do you ernestly think that people, who you thaught to be high school students in 1999 are still at high school?  ;)


    No, I meant there were a team, not only one person :)


So if it is a person then he graduated from high school, if it is a team they are still in high school? :P

Taaz

High school has no relation to my comments about team work vs one person there, it seems that you can't understand.
anyway it doesn't matter.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: FreePascal made it to project of the month on Sourceforge
« Reply #38 on: April 18, 2014, 11:31:53 am »
I was only kidding. just kidding.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

motaz

  • Sr. Member
  • ****
  • Posts: 495
    • http://code.sd
Re: FreePascal made it to project of the month on Sourceforge
« Reply #39 on: April 18, 2014, 12:16:03 pm »
Quote
I was only kidding. just kidding.
I thought you still can't understand :)
sorry

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: FreePascal made it to project of the month on Sourceforge
« Reply #40 on: April 18, 2014, 01:52:38 pm »
Quote
Actually, I use anonymous method in Delphi and I haven't noticed nor I heard that it results in significant exe size increment.
Do you have a lot of anonymous methods with similar body?

Anonymous methods generate some code yes. For each afaik an interface is defined, plus code to move the captured state to the interface. But that is normal overhead, like adding a small class and one or two methods with say an automated type as parameter. Nothing extreme.

The extended RTTI is really a totally different magnitude, and to a lesser degree also generics (afaik though, Delphi doesn't really try to optimize generics(*), so the implementation is actually worse than the design).

(*) Delphi generics contrary to the earlier FPC and C++ ones follows a strict declare before use principle. This makes it much easier to share implementations for cases that only differ in typing. Exploiting this properly is probably a global optimization of which Delphi has few.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: FreePascal made it to project of the month on Sourceforge
« Reply #41 on: April 21, 2014, 03:36:37 pm »
Congratulations! Long live Free Pascal!  :)

Thanks Florian and the FPC team, your work is greatly appreciated.

Cheers,
Frederick
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

nsunny

  • Full Member
  • ***
  • Posts: 117
  • Code is magic
    • LazPlanet
Re: FreePascal made it to project of the month on Sourceforge
« Reply #42 on: April 22, 2014, 07:13:32 pm »
This is the sign for Rise of Lazarus/Free Pascal. I get the feeling that Pascal will once again be popular. I hope it gets the spotlight it deserves.

Congrats to Lazarus/FPC team.
Lazarus TTS Tutorial | LazPlanet
Lazarus 2.2.0 | FPC 3.2.2 | Linux/OpenBSD/ReactOS

BeniBela

  • Hero Member
  • *****
  • Posts: 905
    • homepage
Re: FreePascal made it to project of the month on Sourceforge
« Reply #43 on: April 22, 2014, 07:22:20 pm »
I get the feeling that Pascal will once again be popular.

To become popular it needs to get much more awards, and that soon:

https://lh6.googleusercontent.com/-mv1puZ-1t5k/U0tu-L4GoYI/AAAAAAAAAJ0/1bbOo9KvmUg/w1202-h752-no/13-18.png

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: FreePascal made it to project of the month on Sourceforge
« Reply #44 on: May 06, 2014, 04:16:26 am »
No one has been promoting ObjectPascal for a decade or more so thats not surprising, but it could soon get somewhat exciting. Who knows what will happen when a fantastic product, that doesn't cost anything, comes into the view of more and more people.

I think Pascal lovers have reasons to be optimistic.
« Last Edit: May 06, 2014, 07:42:59 pm by kapibara »
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

 

TinyPortal © 2005-2018