Re: [fpc-pascal] Who said Pascal isn't popular

2009-10-18 Thread Ingemar Ragnemalm

"Vinzent H?fler"  wrote:


Graeme Geldenhuys :

  

Any programmer worth hiring should find it relatively easy to switch
to another language. Or and least become proficient in it in a
relative short period of time.  The basic principles apply to all
languages, it's just the tool-chain and syntax that differs.



Yes and no. The mindsets of the languages may differ. Try talking about typing 
with a C-programmer and with an Ada-programmer and you'll see what I mean.

That's why the question should not be: "Which language do you know?", but rather "What other 
languages do you know?" It tells me more about the mindset of the programmer than any "previous 
10-years experience with $LANGUAGE".
  


Good point there. Anyone who only knows one language is likely to be 
unable to adapt even to the changes in that particular language. For us 
who have moved between languages, it is more natural to adapt.


Don't learn a language; learn to program. Big difference. I think C and 
Java are particularly bad choices to teach programming, and learning 
just the one that "they use in the industry" only makes you 
narrow-minded and limited.



/Ingemar

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] [admin] Who said Pascal isn't popular

2009-10-18 Thread Jonas Maebe

Hello,

Please continue this thread to the fpc-other mailing list. This list  
is for discussions about *programming* in Pascal and FPC, and moreover  
language advocacy threads have a tendency to drown everything else by  
the sheer volume of posts they elicit.


Thanks,


Jonas
FPC mailing lists admin


This message was sent using IMP, the Internet Messaging Program.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Division by Zero: EDivByZero and EZeroDivide

2009-10-18 Thread Tom Verhoeff
On Sat, Oct 17, 2009 at 01:57:28PM +0200, Bart wrote:
> 
> Is there a reason why in fpc both floating point and integer division
> by zero raise an EDivByZero exception?
> 
> See: http://docwiki.embarcadero.com/VCL/en/SysUtils.EZeroDivide
> 
> SysUtils.EZeroDivide exception is raised when an application attempts
> to divide a floating-point value by zero.
> Note:  Integer divide-by-zero errors raise the SysUtils.EDivByZero exception.

It would be nicer if one had the ability to make floating-point division
by zero return an IEEE 754 plus/minus infinity, without raising an
exception.  This is e.g. useful when one needs to evaluate rational
functions.  Without such an infinity, you need to make a nasty case
analysis, which furthermore depends on the rational function.

A simple example is the situation where one needs to calculate
the replacement resistor value R for parallel resistors having
values R1, R2, ..., Rk.  The formula is R = 1/(1/R1 + 1/R2 + ... + 1/Rk).
The formula gives a divide-by-zero if one of the resistors has value 0.
But in that case, the replacement value R also equals 0.  When allowing
infinities, it just works out fine (infinity + x = infinity, 1/infty = 0).
That is precisely why IEEE 754 has infinities.  Also see



for other examples and further motivation.

Unfortunately, many compilers still do not fully support the IEEE 754
floating-point standard.

Best regards,

Tom
-- 
E-MAIL: T.Verhoeff @ TUE.NL | Dept. of Math. & Comp. Science
PHONE:  +31 40 247 41 25| Technische Universiteit Eindhoven
FAX:+31 40 247 54 04| PO Box 513, NL-5600 MB Eindhoven
http://www.win.tue.nl/~wstomv/  | The Netherlands
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Division by Zero: EDivByZero and EZeroDivide

2009-10-18 Thread Jorge Aldo G. de F. Junior
Wouldnt a NaN (Not a number) be more "matematically correct" result (I saw
that on an old book about i387)

Matematically division by zero is an "mathematical impossibility", so NaN
would be more logical

Is there a way to deal with NaN's and other i387 (and similars) conventions
directly in Pascal ?

Something like :

If A / B = NaN then something();

2009/10/18 Tom Verhoeff 

> On Sat, Oct 17, 2009 at 01:57:28PM +0200, Bart wrote:
> >
> > Is there a reason why in fpc both floating point and integer division
> > by zero raise an EDivByZero exception?
> >
> > See: http://docwiki.embarcadero.com/VCL/en/SysUtils.EZeroDivide
> >
> > SysUtils.EZeroDivide exception is raised when an application attempts
> > to divide a floating-point value by zero.
> > Note:  Integer divide-by-zero errors raise the SysUtils.EDivByZero
> exception.
>
> It would be nicer if one had the ability to make floating-point division
> by zero return an IEEE 754 plus/minus infinity, without raising an
> exception.  This is e.g. useful when one needs to evaluate rational
> functions.  Without such an infinity, you need to make a nasty case
> analysis, which furthermore depends on the rational function.
>
> A simple example is the situation where one needs to calculate
> the replacement resistor value R for parallel resistors having
> values R1, R2, ..., Rk.  The formula is R = 1/(1/R1 + 1/R2 + ... + 1/Rk).
> The formula gives a divide-by-zero if one of the resistors has value 0.
> But in that case, the replacement value R also equals 0.  When allowing
> infinities, it just works out fine (infinity + x = infinity, 1/infty = 0).
> That is precisely why IEEE 754 has infinities.  Also see
>
>
> 
> >
>
> for other examples and further motivation.
>
> Unfortunately, many compilers still do not fully support the IEEE 754
> floating-point standard.
>
> Best regards,
>
>Tom
> --
> E-MAIL: T.Verhoeff @ TUE.NL | Dept. of Math. & Comp. Science
> PHONE:  +31 40 247 41 25| Technische Universiteit Eindhoven
> FAX:+31 40 247 54 04| PO Box 513, NL-5600 MB Eindhoven
> http://www.win.tue.nl/~wstomv/   | The
> Netherlands
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Division by Zero: EDivByZero and EZeroDivide

2009-10-18 Thread Jürgen Hestermann
Is there a way to deal with NaN's and other i387 (and similars) 
conventions directly in Pascal ?


Yes, if not yet possible (I didn't have a closer look) I would like to 
have that too. But I think it's heavily depending on the processor...


(Details about NaN's and infinity at http://en.wikipedia.org/wiki/NaN)


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Division by Zero: EDivByZero and EZeroDivide

2009-10-18 Thread Aleksa Todorovic
On Sun, Oct 18, 2009 at 18:49, Jorge Aldo G. de F. Junior
 wrote:
> Wouldnt a NaN (Not a number) be more "matematically correct" result (I saw
> that on an old book about i387)
>
> Matematically division by zero is an "mathematical impossibility", so NaN
> would be more logical
>
> Is there a way to deal with NaN's and other i387 (and similars) conventions
> directly in Pascal ?

Take a look at SysUtils, functions IsNaN, IsInfinite.

>
> 2009/10/18 Tom Verhoeff 
>>
>> On Sat, Oct 17, 2009 at 01:57:28PM +0200, Bart wrote:
>> >
>> > Is there a reason why in fpc both floating point and integer division
>> > by zero raise an EDivByZero exception?
>> >
>> > See: http://docwiki.embarcadero.com/VCL/en/SysUtils.EZeroDivide
>> >
>> > SysUtils.EZeroDivide exception is raised when an application attempts
>> > to divide a floating-point value by zero.
>> > Note:  Integer divide-by-zero errors raise the SysUtils.EDivByZero
>> > exception.

Maybe because is more consistent to have one type for both exceptions
- when you see it, you know what it means. How could anybody make
distinction between EDivByZero and EZeroDivide without looking at
documentation?

>>
>> It would be nicer if one had the ability to make floating-point division
>> by zero return an IEEE 754 plus/minus infinity, without raising an
>> exception.  This is e.g. useful when one needs to evaluate rational
>> functions.  Without such an infinity, you need to make a nasty case
>> analysis, which furthermore depends on the rational function.
>>

There is function SetExceptionMask in SysUtils which you can use to
control which exceptions will be thrown at runtime. I haven't used it,
but looks like a good place to start...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] BNF grammar for fpc

2009-10-18 Thread leledumbo

> That may be because it is no longer possible to write a BNF grammar for
> these compilers due to the c-style extensions.

AFAIK if a parser can be made for an extension, so is the grammar.

> There are some language constructs that is simply not posible with a LL(1)
> parser,
> when comparing to the LALR(1).

For example, left recursion. Yes, I know LALR(1) can recognize this. But it
can be solved easily by transforming the grammar such that the recursion is
eliminated and LL(1) wins again.
-- 
View this message in context: 
http://www.nabble.com/BNF-grammar-for-fpc-tp25914637p25952532.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal