Recent

Author Topic: function MyFunction_Procedure() : Nil ?  (Read 4476 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 2029
    • StrumPract is the musicians best friend
function MyFunction_Procedure() : Nil ?
« on: July 16, 2014, 12:59:41 pm »
WARNING : This is only a idea in the air. Im totally happy with existing feature...

Now the thing:

In Pascal there are functions and procedures.

Functions  are actions with output-result.
Procedures are actions without output-result.

Could it be nice to group both concepts into one ?

It will remain then only functions.

Here a function with result :
Code: [Select]
function MyFunction_Function() : integer
And here a function without result (a procedure in Pascal) :
Code: [Select]
function MyFunction_Procedure() : nil
PS: Yes, i agree, the idea comes from the C "void" method...

Thanks.



« Last Edit: July 16, 2014, 01:05:57 pm by Fred vS »
I use Lazarus 2.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs
https://gitlab.com/fredvs

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9014
  • FPC developer.
Re: function MyFunction_Procedure() : Nil ?
« Reply #1 on: July 16, 2014, 01:22:19 pm »
Actually the Pascal successor Modula2 did this and named everything procedure in 1980, so you are a bit late with this. It also illustrates the problem with these kind of things, if you change base syntax, then compatibility is usually more important than stylistic rearrangements, and suddenly you have two languages.

Personally I think it is totally unimportant to begin with.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2544
    • havefunsoft.com
Re: function MyFunction_Procedure() : Nil ?
« Reply #2 on: July 16, 2014, 02:40:59 pm »
Could it be nice to group both concepts into one ?
rather than having "nil" as a type (nil is not a type it's a reserved word / constant value), you can leave function declaration without a type
Code: [Select]
function MyFunction_Function();
that will make it a procedure. (no hidden "Result"/functionName variable)

I think Oxygen does that? ... nah... it's "method" keyword there... well.. it was in one of pascal implementations.
« Last Edit: July 16, 2014, 02:44:03 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Rails

  • Guest
Re: function MyFunction_Procedure() : Nil ?
« Reply #3 on: July 16, 2014, 03:13:04 pm »
Could it be nice to group both concepts into one ?
rather than having "nil" as a type (nil is not a type it's a reserved word / constant value), you can leave function declaration without a type
Code: [Select]
function MyFunction_Function();
that will make it a procedure. (no hidden "Result"/functionName variable)


That results in an error on my system  --  Fatal: Syntax error, ":" expected but ";" found

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2544
    • havefunsoft.com
Re: function MyFunction_Procedure() : Nil ?
« Reply #4 on: July 16, 2014, 03:19:26 pm »
That results in an error on my system  --  Fatal: Syntax error, ":" expected but ";" found
did you try it on FPC 2.9.1? if not then you're using a wrong version of the compiler.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Rails

  • Guest
Re: function MyFunction_Procedure() : Nil ?
« Reply #5 on: July 16, 2014, 04:12:10 pm »
That results in an error on my system  --  Fatal: Syntax error, ":" expected but ";" found
did you try it on FPC 2.9.1? if not then you're using a wrong version of the compiler.

I am using the current production version, 2.6.4.  How can that be wrong version.?

If you are saying that the development version now supports functions without result types as a new feature, that is another matter.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2544
    • havefunsoft.com
Re: function MyFunction_Procedure() : Nil ?
« Reply #6 on: July 16, 2014, 04:20:59 pm »
I am using the current production version, 2.6.4.  How can that be wrong version.?

If you are saying that the development version now supports functions without result types as a new feature, that is another matter.
it is in development. (that's why the subject is in "suggestions")

ok, so here's how you can reach out the functionality.
get the latest compiler version from trunk (aka 2.7.1) and apply the patch typelessfunc.diff -> welcome to 2.9.1!

the test application is attached to this post as well!

needless to say, since typeless functions are not really backward compatible, using {$modeswitch typelessfunc} is mandatory!
« Last Edit: July 16, 2014, 04:31:42 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Fred vS

  • Hero Member
  • *****
  • Posts: 2029
    • StrumPract is the musicians best friend
Re: function MyFunction_Procedure() : Nil ?
« Reply #7 on: July 17, 2014, 04:12:35 pm »
Quote
Personally I think it is totally unimportant to begin with.

Me too.  :-X

@  skalogryz =>  :)   :D  ;)

I use Lazarus 2.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs
https://gitlab.com/fredvs

 

TinyPortal © 2005-2018