Search code examples
typesluatorch

Is lua a dynamically typed language?


Is lua a dynamically typed language?

If it is, why is there a difference between normal Tensor and CudaTensor?

For example:

a = torch.Tensor(5,5):zero() 

and

b = torch.CudaTensor(5,5):zero()

Solution

  • https://www.lua.org/manual/5.3/manual.html#2.1

    Chapter 2: Basic Concepts:

    2.1 Values and Types:

    Lua is a dynamically typed language. This means that variables do not have types; only values do. There are no type definitions in the language. All values carry their own type.

    Tensor and CudaTensor have nothing to do with Lua btw.. They're part of the third party library Torch. I haven't worked with torch yet but a torch.Tensor is most likely a Lua table or userdata.

    Torch may provide it's own type() function to emulate more "types" though.