Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
Am 12.01.2011 08:00, schrieb Paul Ishenin: 12.01.2011 13:54, kingbiz...@gmail.com пишет: Well guys, thanks for replying, the generic method is a very nice method, I personally didn't know that the FPC support it, very thank you for that! FPC does not support it at the moment. I hope it will in a month. Oh wow O.o That's why I love Free Pascal... Btw: Do you plan to implement constraints as well? Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
12.01.2011 15:20, Sven Barth wrote: Btw: Do you plan to implement constraints as well? I thought to implement all what delphi has but I don't know whether I will be able to. Best regards, Paul Ishenin ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
kingbiz...@gmail.com wrote: I come here humbly to ask for a new implementation, the IIF ?:, the IIF is a shortcut that make the coding a little faster, it works by returning a true or a false part of a condition, a more detailed information can be found there: http://en.wikipedia.org/wiki/%3F: *PHP and C++ implementation:* Value *=* condition *?* value if true *:* value if false; *Pascal implementation:* Value := IfThen(Condition, TruePart, FalsePart); *function IfThen(Condition: Boolean; IfTrue, IfFalse: X): X; overload; begin if Condition then Result := IfTrue else Result := IfFalse; end; * Note that there is a tiny little difference between those two. the ?: operator evaluates either the TruePart or FalsePart while IfThen will evaluate both parts first. The following will succeed var p: PInteger; i: Integer; begin p := nil; i := p nil ? p^ : 0; end; The following will fail var p: PInteger; i: Integer; begin p := nil; i := IfThen(p nil, p^ , 0); end; ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
On Thu, Jan 13, 2011 at 00:51, Marc Weustink marc.weust...@cuperus.nl wrote: Note that there is a tiny little difference between those two. the ?: operator evaluates either the TruePart or FalsePart while IfThen will evaluate both parts first. Exactly. This is why for me IfThen is much less useful then conditional operators in other languages. I think a better alternative would be Algol-like if-expression: a := (if x 0 then x else -x); -- Alexander S. Klenin ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
kingbiz...@gmail.com schrieb: I come here humbly to ask for a new implementation, the IIF ?:, the IIF is a shortcut that make the coding a little faster, it works by returning a true or a false part of a condition, a more detailed information can be found there: http://en.wikipedia.org/wiki/%3F: *PHP and C++ implementation:* Value *=* condition *?* value if true *:* value if false; *Pascal implementation:* Value := IfThen(Condition, TruePart, FalsePart); The standard Pascal implementation of the C ternary expression is a const Name: array[boolean] of type = (FalseFart, TruePart); and Value := Name[Condition]; DoDi ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
12.01.2011 13:28, kingbiz...@gmail.com wrote: The problem: we have to do *one function for every type*, on the C and PHP method is is *globally* If we want one for Integer we must declare one for it, if we want one for X we need to declare it... I want to know from you, what you would think about it on FPC? I don't belive that it is a hard feature to implement and is helpfull. I'll be waiting for your response! Similar to delphi generic method: function IIfT(Condition: Boolean; IfTrue, IfFalse: T): T; begin if Condition then Result := IfTrue else Result := IfFalse; end; I'm working on this functionality for classes, objects and record methods. But even delphi does not have it for regular procedures/functions. I suppose because regular procedures/functions does not support overloading. Best regards, Paul Ishenin ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
In our previous episode, Paul Ishenin said: But even delphi does not have it for regular procedures/functions. I suppose because regular procedures/functions does not support overloading. ??? I use it all the time? Requires overload directive iirc, but works. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
12.01.2011 13:47, Marco van de Voort пишет: In our previous episode, Paul Ishenin said: But even delphi does not have it for regular procedures/functions. I suppose because regular procedures/functions does not support overloading. ??? I use it all the time? Requires overload directive iirc, but works. Indeed... I somehow have misled myself. Well, then I don't know the reason why delphi does not have generic functions/procedures. Best regards, Paul Ishenin ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
Em 12/01/2011 04:47, Marco van de Voort escreveu: In our previous episode, Paul Ishenin said: But even delphi does not have it for regular procedures/functions. I suppose because regular procedures/functions does not support overloading. ??? I use it all the time? Requires overload directive iirc, but works. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel Well guys, thanks for replying, the generic method is a very nice method, I personally didn't know that the FPC support it, very thank you for that! ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
12.01.2011 13:54, kingbiz...@gmail.com пишет: Well guys, thanks for replying, the generic method is a very nice method, I personally didn't know that the FPC support it, very thank you for that! FPC does not support it at the moment. I hope it will in a month. Best regards, Paul Ishenin ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proposal: IIF - IfThen Cond True False
Em 12/01/2011 05:00, Paul Ishenin escreveu: 12.01.2011 13:54, kingbiz...@gmail.com пишет: Well guys, thanks for replying, the generic method is a very nice method, I personally didn't know that the FPC support it, very thank you for that! FPC does not support it at the moment. I hope it will in a month. Best regards, Paul Ishenin ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel Ok, I'll be waiting for that! Guys, you reply fast and nice! Thank you again, anyways =) ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel