Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Dynamic typing

Name: Anonymous 2016-12-09 22:15

...is just one type you have no control over.

Name: Anonymous 2016-12-09 22:21

As opposed to having the illusion of control. The government is going to do what they want with your data anyway.

Name: Anonymous 2016-12-09 23:10

Dynamic typing is good for some hundred lines scripts.

Name: Anonymous 2016-12-10 0:24

Turret referred referred jinni minimum junk juju jinni juju loop polio lollipop assess assesses assesses assess sees

Name: Anonymous 2016-12-10 3:33

>>4
I can't parse that!

Name: Anonymous 2016-12-12 5:22

>>1
Lie

Name: sage 2016-12-12 12:11

var x = 4; // x is a Number
x = []; // x is an Array


You have total control over what type of variable x is.

Name: Anonymous 2016-12-12 12:25

Name: Anonymous 2016-12-12 14:05

>>7
An array is a container not a type.

Name: Anonymous 2016-12-13 0:56

>>9
Wrong.

Name: Sega 2016-12-14 2:24

>>10
Wrong

Name: Anonymous 2016-12-14 12:24

U mena "type constructor" >>9

Name: Anonymous 2016-12-14 13:20

>>12
No, I don't.

Name: Anonymous 2016-12-14 16:43

>>10
It's true though, Array in Javascript is not a type.

Name: Anonymous 2016-12-15 4:17

>>14
Correct. Array in JavaScript is merely a constructor function.

Individual arrays are not identified as arrays by the dynamic type system, but rather as objects:

typeof [1, 2, 3] // "object"

Therefore, like any other JS object, an "array" can be made to act as a dictionary:

var x = [1, 2];
x.anus = "haxed";
Object.keys(x); // ["0", "1", "anus"]


So with no help from the type system, how to tell if an array is really an array?

Well for starters, an array refers to the Array function as its constructor property:

[1, 2, 3].constructor // function Array() { [native code] }
new Array().constructor // function Array() { [native code] }


And their prototype is obviously the Array prototype:

[].__proto__ === Array.prototype // true

And the internal [[Class]] property will also reveal arrayness, which can be observed using Object.prototype.toString (note: this looks stupid but it's the most reliable method):

Object.prototype.toString([1, 2]) // "[object Array]"

Unfortunatey, there are objects (arguments is one) that behave as arrays for many purposes and yet don't fulfill the previous 3 conditions I mentioned:

(function() {
// Looks like an array...
arguments[0] // "hello"
arguments[1] // "there"
arguments.length // 2

// But isn't really
arguments.constructor; // function Object() { [native code] }
Object.prototype.toString(arguments); // "[object Object]"
arguments.__proto__ // Object.prototype
}('hello', 'there'))

Name: Anonymous 2016-12-15 7:42

Objects in JS are actually associative arrays which can nest to arbitrary depth.

Name: Anonymous 2016-12-15 7:50

>>16
learn2prototype-OOP

Name: Anonymous 2016-12-15 9:19

>>17
Its actually a hack which looks up key[properties] in one of parent arrays(and parent array==assigned constructor).
Basically when Par3.Par2.Par1.Obj["X-property"] lookup fails it looks it up in the parent array Par1, and if it fails Par2 etc.

Name: Anonymous 2016-12-15 11:20

The point is that dynamic typing doesn't mean that there is only one type over which you have no control. The point is that you have control over what type a var is at any point during the program's execution, and that OP is a giant faggot.

Name: Anonymous 2016-12-17 20:49

>>7
No, in fact you can't even express these types with the language. From the compiler's point of view, x has the same type whether it's equal to 4 or to [] - otherwise it would issue an error when you tried

var x = 4
var y = x[0]

Name: Anonymous 2016-12-17 20:52

>>19
You have control over what type a var is, because you can't even say "this var is this type now, mmkay" as there is no way to express types in the language. Thus OP is right and you're the giant faggot.

Name: Anonymous 2016-12-17 20:53

* You have no control

Name: Anonymous 2016-12-17 21:34

>>22
Bad Dubs

Name: Anonymous 2016-12-19 11:45

>>21
variables don't have types
values have types

Name: Anonymous 2016-12-19 13:26

>>24
Variables have types. Values are interpreted according to the type of variable.

Name: Anonymous 2016-12-19 19:35

>>25
Not in scripting languages. Variables in those languages are just names (essentially pointers) to an object on the heap, which does have a type.

Name: Anonymous 2016-12-19 23:55

>>25
That's exactly what I mean when I say variables have types and value are interpreted. If I take an arbitrary bitstring, I can choose to interpret that bitstring as an 8 bit character array. I can easily take that bitstring and interpret it as an unsigned floating point variable or even a binary coded decimal number. The bitstring value has not changed at all but my interpretation of the meaning of this bitstring changes when I choose to reinterpret the type of this value. The variable is simply a label that tells the programmer where the value is located in memory and also the proper way to interpret the variable type.

Name: Anonymous 2016-12-20 12:41

>>26
Wow that's really e/g//g/in /g/roski

Name: Anonymous 2016-12-23 6:28

JACKSON 5 GET

Name: Anonymous 2016-12-24 18:21

>>26
Even in scripting languages, variables have a type and that type is Any. The objects on the heap, however, do not have a type. Types are something at the language level, not at the machine representation level. What heap objects have are runtime classification tags, much like the A, B, C etc in the following:

data Any = A Int | B String | C (Array Int) | ...

A, B and C are obviously not different types, they are tags (language-level as well as runtime-level) that distinguish values of a single type.

Name: Anonymous 2016-12-25 5:56

>>30
wow ur a faget

Name: Anonymous 2016-12-25 11:24

>>31
cool story bro

Name: Anonymous 2016-12-26 1:15

>>32
now checkem

Name: Anonymous 2016-12-26 10:43

>>30
What are "tags"?

Name: Anonymous 2016-12-29 15:22

>>34
so called "tags" do not exist, move along

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List