axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] B#


From: Gabriel Dos Reis
Subject: Re: [Axiom-developer] B#
Date: 21 Nov 2005 18:58:50 +0100

"Bill Page" <address@hidden> writes:

| On November 20, 2005 11:50 PM Gaby wrote:
| > | 
| > | We have mentioned before on this list the very good article
| > | 
| > | http://en.wikipedia.org/wiki/Datatype
| > | 
| > | about type systems in programming languages. "strong type
| > | checking" has several different definitions but I think most
| > | people would agree that Lisp is a strong dynamically typed
| > | language by most of these definitions.
| > 
| > That is interesting but the link above is confused to start with.
| > I quote: 
| > 
| >    An example of the absence of strong typing is a C cast 
| >    gone wrong; if you cast a value in C, not only is the
| >    compiler required to allow the code, but the runtime is
| >    expected to allow it as well.
| > 
| > That is misleading at best. The core C system is consistent 
| > -- the only trouble is that I would be in difficult position
| > to prove it, in the mathematical sense because I have not sense
| > any formal definition of C in the mathematical sense.  However,
| > the fundamental point is that if you make a cast, the runtime is
| > not required to accept it if it is semantically ill-formed. And
| > the compiler is not required to accept it if it can somehow
| > determine that it is invalid.  In fact, we're seeing more
| > compilers taking advantages of those semantics invariants, in
| > terms of optimizations.
| >
| 
| I think you are wrong.

No -- sorry, Bill you can't have it right on this one.

| For example consider this example:
| 
| /*
|   'caste' example of weak typing in C
|    Author: Bill Page
|    Date: 21 Nov 2005
| */
| #include <stdio.h>
| int main(int argn, char *argv[]) {
| float j;
| 
|   (int)j = 1;
|   printf("float: %d\n",j);
|   return 0;
| }
| 
| ------
| 
| You can compile this with gcc without errors and it runs without
| error. What result would you expect it to return?

Your program is ill-formed according to ISO C rules and semantics and
my compiler rightly rejects it:

    merlin[12:54]% cat bill-page.c && gcc bill-page.c
    /*
        'caste' example of weak typing in C
           Author: Bill Page
              Date: 21 Nov 2005
    */
    #include <stdio.h>
    int main(int argn, char *argv[]) {
       float j;

       (int)j = 1;
       printf("float: %d\n",j);
       return 0;
    }
    bill-page.c: In function 'main':
    bill-page.c:10: error: invalid lvalue in assignment


| I still think the referenced article is well balanced and
| accurate.

I don't think so  If is full of confusion and misunderstanding.
Unfortunately, many people take it as a Bible sentence don't go and do
a minimum scrutinity as would be required in a scientific setting :-(

-- Gaby




reply via email to

[Prev in Thread] Current Thread [Next in Thread]