Re: Re: Re: Re: php-cli vs python



Nathan Nobbe dedi ki:

Admittedly, there are some annoying features of PHP, the most
annoying one being its "dynamic" typing (opposed to "weak" typing).

I think its worth mentioning that 'dynamic' and 'weak' typing both refer
to type checking, yet they refer to different aspects of type checking.
a lanuguage is either dynamically or statically typed and either weakly
or strongly typed, going by wikipedia:
http://en.wikipedia.org/wiki/Type_checking#Type_checking

and PHP is supposedly dynamically, weakly typed
http://en.wikipedia.org/wiki/Php

My sloppy terminology use. Still not sure about the precise terminology,
but what I meant might be called as "unavoidable dynamic casting". For
instance, I once wanted to XOR a 128 bit binary string variable with a 128
bit binary constant string. Unable to express a binary string in a
straightforward way, I resorted to "pack" it like this:

$key = pack("N*", 0x12345678, 0x9abcdef0, 0x87654321, 0x0fedcba9);

Well, second and third 32-bit hex values were automatically converted by
PHP to float, before packing, because PHP tries to cast them into signed
32-bit integers, which can't be represented with, as they're above
0x7fffffff (2^31-1). So, PHP casts them to floats. As a workaround I had
to use modulo-8 values for the top hex digits. (E.g. 0x1abcdef0 instead of
0x9abcdef0).

No way to say "Just take these bytes and pack them together, as is". Every
operation goes through PHP's own type juggling pipe. I can do explicit
casting, but not always - as in the example above. (It's possibly just my
lack of grip on PHP).

I wish PHP6 would bring along a feature to arbitrarily control or disable
dynamic casting. Without auto-casting, treating everything as byte
strings. E.g. if the user says

$x = "A" + 5;

and if auto casting is disabled, then just adding their internal
representations (0x41 + 0x05 giving 0x46) like an assembler. Sometimes I
want to take all the responsibility of disabling typing, and instruct
PHP "please do it as is, and let me worry if it makes sense or not".

Perhaps there's already a way to do this?..

Kind regards,
--
Abdullah Ramazanoglu
aramazan ÄT myrealbox D0T cöm
.



Relevant Pages

  • [FAQ] FAQ Thread (Rev 5)
    ... Q: How to run PHP? ... Refer: ... Referer headers, for example, while others can be configured ... set a cookie or session variable and expect ...
    (comp.lang.php)
  • Re: Braehead Centre - Rumour
    ... Perhaps you could refer them to your book - except that it isnae ... Well, until it's written, I suspect any reference whatsoever you make ... I'm fucked if i can see php mentioned anywhere in the above. ...
    (uk.local.glasgow)
  • Re: Braehead Centre - Rumour
    ... colour and just assumes everybody uses the default windows white. ... Perhaps you could refer them to your book - except that it isnae ... Well, until it's written, I suspect any reference whatsoever you make ... I'm fucked if i can see php mentioned anywhere in the above. ...
    (uk.local.glasgow)
  • GET ? parameters not accessible
    ... weirdness I can't figure out the variable is not defined on the page after ... I have done this before on other websites using the same versions of PHP so ... Shouldn't I be able to refer to ...
    (alt.php)
  • Re: Convert PHP pack() function to C#
    ... PHP has a function called pack(). ... translate some code that uses this function to C#. What's the C# ... it converts string into binary string where first parameter ...
    (microsoft.public.dotnet.languages.csharp)