Dynamically typed

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Why scripting languages are dynamically and weakly typed? and why none
of the scripting languages is compiler based?
why cant a scripting  language be use like java or c++ where we can
catch type errors e.g. (string being assigned to an integer),
parameter passing at compiled time.

what is the significance of multiple dollar sign ($$...$var) in php?
$var = "profession";
$$var = "doctor";
$$$var = "khalid";
and so on...

Re: Dynamically typed

munna wrote:

Quoted text here. Click to load it

Why do I always end up in a trafficjam if I take the car?
Why do I browse this newsgroup, and answer this question while your negative  
attitude irritates me a little?
Why do I always end up with a hangover if I drink a lot?
and so on...

To your 'questions':

- PHP juggles types around to make things easier, at least that was the  
intent of the builders.
If you don't like loose typed variables, cast them to something you DO like  
when you use them.
$someVar = "12.3";
now $someVar is a string, however, if you use it like:
$summed = 12 + $someVar;
it will be interpreted as a float.

So if you want your variables strongtyped, pick another language or cast  
them always before using.

Start here: http://nl3.php.net/manual/en/langref.php
Read at least that whole chapter (Language reference) before asking basic  

About the $ sign, it is a substitutemethod for variable-adressing.
$var = "profession";

// Simple: Now $var contains a String.

$$var = "doctor";

Now you created a variable named $profession with value "doctor".

$$$var = "khalid";

No clue, probably more of the same.
I never use such strange languageconstructs.

Erwin Moller

Re: Dynamically typed

Erwin Moller wrote:
Quoted text here. Click to load it

The problem, you see, is that beverages aren't strongly typed. You can
pass vodka to your month just as easier as water.  So people end up
getting serious runtime errors at parties, football matches, and such,
when they inadvertently drink the wrong substance.

Re: Dynamically typed

I think those people explicitly want to support the DrinkableLiquid  
superclass instead of just the NonAlcoholic subclass ;)

Chung Leong wrote:
Quoted text here. Click to load it

Re: Dynamically typed

Quoted text here. Click to load it

In my experience there is no good definition for 'scripting language'
and thus is making the distinction between 'programming language' and
'scripting language' useless.

Quoted text here. Click to load it

Actually there are programming languages (which you would name
'scripting languages) that support this.  

Even PHP5 supports this feature (be it limited to custom classes though...)  

Quoted text here. Click to load it

rtfm (section on variable variables)

Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be

Site Timeline