Dynamically typed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • munna

    #1

    Dynamically typed

    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?
    e.g.
    $var = "profession ";
    $$var = "doctor";
    $$$var = "khalid";
    and so on...

  • Erwin Moller

    #2
    Re: Dynamically typed

    munna wrote:
    [color=blue]
    > 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?
    > e.g.
    > $var = "profession ";
    > $$var = "doctor";
    > $$$var = "khalid";
    > and so on...[/color]

    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
    questions.

    About the $ sign, it is a substitutemetho d 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 languageconstru cts.

    Regards,
    Erwin Moller

    Comment

    • Chung Leong

      #3
      Re: Dynamically typed

      Erwin Moller wrote:[color=blue]
      > Why do I always end up with a hangover if I drink a lot?
      > and so on...[/color]

      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.

      Comment

      • Tim Van Wassenhove

        #4
        Re: Dynamically typed

        On 2006-05-17, munna <hassaan84s@gma il.com> wrote:[color=blue]
        > Why scripting languages are dynamically and weakly typed? and why none
        > of the scripting languages is compiler based?[/color]

        In my experience there is no good definition for 'scripting language'
        and thus is making the distinction between 'programming language' and
        'scripting language' useless.
        [color=blue]
        > 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.[/color]

        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...)

        [color=blue]
        > what is the significance of multiple dollar sign ($$...$var) in php?[/color]

        rtfm (section on variable variables)

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

        Comment

        • Dikkie Dik

          #5
          Re: Dynamically typed

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

          Chung Leong wrote:[color=blue]
          > Erwin Moller wrote:[color=green]
          >> Why do I always end up with a hangover if I drink a lot?
          >> and so on...[/color]
          >
          > 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.
          >[/color]

          Comment

          Working...