Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About self:calls() in the timer lib #60

Closed
ghost opened this issue Feb 4, 2016 · 2 comments
Closed

About self:calls() in the timer lib #60

ghost opened this issue Feb 4, 2016 · 2 comments
Assignees

Comments

@ghost
Copy link

ghost commented Feb 4, 2016

I realize there was an issue about this a while ago, but I just keep scratching my head at this the more I work with it, and it's bit me in the ass more times than I'd prefer.

-- hump.camera:
local cam = Camera()
cam:moveto(1337, 1337) -- self call


-- hump.vector:
local vec = Vector(573, 573)
vec:normalize() -- self call


-- hump.class:
Person = Class{
  init = function(self, name) self.name = name end,
  speak = function(self) print('my name is', self.name) end,
}

local p = Person()
person:speak() -- self call (though completely necessary as per what the library does)


-- hump.timer:
local timer = Timer()
timer.update(dt) -- ...no self call.

I... can't say I understand why the timer is inconsistent with the usage of the rest of the libraries. Only now have I noticed that hump.signal seems the same way.

When something is required globally as a library, it is to receive no self as a standard. However, instances should be receiving self in their function calls because they're instances, no? They should be operating on a given self as per basic logic of OOP, not on an invisible floating self variable somewhere in space, right?

I'm guessing the main difference here is to create consistency between the usage of libraries and that of the one that instances them, but then you're creating inconsistencies not only with the other parts of the lib, but with common lua OOP paradigms themselves ...and in my brain. Code like this is ambiguous and misleading, when everything is created and documented as an instance, but it appears to be a global usage of hump.timer. Other than from the naming of the variable, one wouldn't be able to tell at first glance.

vector:dothing()
camera:dothing()
timer.dothing()
@vrld
Copy link
Owner

vrld commented Apr 18, 2016

Yes, that is a weird and dangerously inconsistent API mishap that should be fixed.

@vrld vrld self-assigned this Apr 18, 2016
@ghost
Copy link
Author

ghost commented May 1, 2016

Great, and apologies if my answer seemed overly wordy. Trying to work on that, heheh.

@vrld vrld closed this as completed in 8435fc7 May 1, 2016
vrld added a commit that referenced this issue May 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant