Re:“A closure is a poor man’s object; an object is a poor ma...
by probablybroken on Monday May 01, 2017 @06:03AM
(#14236513)
It sounds like you are referring to public properties.
Re:“A closure is a poor man’s object; an object is a poor ma...
by justincormack on Monday May 01, 2017 @06:34AM
(#14236606)
In languages like Lua you can always mediate what look syntactically like setters.
Re:“A closure is a poor man’s object; an object is a poor ma...
by DougBTX on Monday May 01, 2017 @11:34AM
(#14238359)
At least in C# terminology, a "setter" for a public property is mediated access, unmediated access would be a public field that can be set without invoking a setter method.
Getters and setters in C# are method calls, like `setFoo` in Java, so can't be assumed to be simple, they can do anything any other method can do.
Re:“A closure is a poor man’s object; an object is a poor ma...
by noblethrasher on Wednesday May 03, 2017 @10:13AM
(#14255796)
As it turns out, C# is a language that I know extremely well; I'm aware that setters can have arbitrary code. But, here's the problem: A programming a language is medium for thought, which means that it promotes or prevents the occurrence of certain ideas.
So, even though the compiler will accept any legal void-returning code within the inner braces of
public Foo Bar
{
set
{
//Do stuff
}
}
The fact that the client code is going to look like `Obj.Foo = whatever` will practically foreclose on all but a small subset of possibilities.
Re:“A closure is a poor man’s object; an object is a poor ma...
by dragonwriter on Monday May 01, 2017 @07:55PM
(#14242861)
But classical setters aren't setters then, because the access is mediated (the are, or are backed by, methods which could do anything.)
Only public fields provide unmediated access.
Re:“A closure is a poor man’s object; an object is a poor ma...
by noblethrasher on Wednesday May 03, 2017 @10:48AM
(#14256117)
Please see my reply to a sibling comment: https://news.ycombinator.com/item?id=14255796
The big idea is that the sender should not be able to assume that the message, `setFoo`, will have any particular effect with respect to the reciever’s state.