I'd love to see DScript one day ...

Chris via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 15 06:17:46 PDT 2016


On Wednesday, 15 June 2016 at 12:14:45 UTC, Ola Fosheim Grøstad 
wrote:
> On Wednesday, 15 June 2016 at 11:33:23 UTC, Chris wrote:
>> But Python for example doesn't care.
>
> Python is fairly dynamic and static analysis tools such as 
> PyCharm helps a lot when you write larger Python projects.
>
>> What you describe is basically trying to mimic static typing.
>
> No, you can have something like this:
>
> var  x = f(42);
>
> if(x>100) freeze x;
>
> // whether x is immutable or not is not statically known at 
> this point

But 'freezing' ain't got nothing to do with the type. It's 
basically D's `immutable`.

In my experience, statically typed languages prevent a lot of 
silly and time consuming bugs by simply checking the type. If, 
after a few changes, function arguments don't match, the compiler 
(or interpreter) complains immediately. In Python the code may 
still work:

`
def loophere(variable):
   for i in variable:
     print (i)

loopy = "Ola, mundo!"
loophere(loopy)
# Developer decides that `loopy` should be a list of strings
loopy = ["Ola", "mundo", "!"]
loophere(loopy)

`




More information about the Digitalmars-d mailing list