Closed airidas338 closed 9 years ago
hm, try normal:test()
?
Returns the same error
It's pretty simple actually:
Maybe E2 needs user-defined types, so he can have a Team type :)
Currently the easiest way to fake objects is to use tables and then create functions on the table type.
Agreed, we should get some user-defined types.
But Divran is already directing people to things that are "better" than E2 so why bother.
@oldmud0 development for E2 has been pretty stale for years
EDIT: doesn't mean we don't randomly get the urge to do small stuff, or accept pull requests
Any update on this issue?
EDIT: We're doing a check here https://github.com/wiremod/wire/blob/master/lua/entities/gmod_wire_expression2/base/parser.lua#L601-L622 to see if the type is normal and if so error out, I removed the line and the number as function object worked fine.
Is their any reason to have that check?
That's weird. I don't see any reason to have that.
Neither did I, maybe caused an old bug? If it did I'd think it's been fixed by now as I wasn't able to produce any errors using numbers as objects.
In this case, I'd say remove it and see if people complain :) You can try doing shenanigans with all the different kinds of number literals to see if they cause problems.
Apparently Syranide did this, just saying
So should we just comment out the line just incase something happens? I mean unless someone can contact Syranide and ask why it was added( doubt he remembers ), we don't have much to go off of. And should I create a pull request for this or would it be easier for someone to commit it directly in?
The only thing that makes sense to me is that it was added to give a useful error message. My thinking probably being that it doesn't really make sense to have methods on numbers, they're "too primitive" in a sense and the only operations that really makes sense are already operators. Anything that operates on numbers are better provided as functions across the board (from a CS perspective).
Anyway, do as you please :) because I can't imagine it being there for any other reason, and it should be immediately obvious if it has to be there (like not parsing).
My thinking probably being that it doesn't really make sense to have methods on numbers, they're "too primitive" in a sense and the only operations that really makes sense are already operators
This is E2, we don't give a fuck
EDIT: as long as it's better than PHP, but we couldn't make E2 worse than PHP even if we tried.
PHP has classes with polymorphism... let's at least add user-defined types. together with method-style they feel like non-polymorphic classes Shorthand would be automatically assigned from a pool of x00..x99, so we have 100 user-defined classes :)
Example: function void number:testFunction() { }
Enable numbers as function object types, so we could create functions similar to these n:teamDeaths(), teamName() which is implemented in E2. (No, i don't want to add number as parameter, this way it looks better, nearly can simulate object based scripting)