4 ms·
Context is not a requirement of the actual act of composition, though; that's what I'm trying to help you understand. Context might be why you might compose tw
by yellowapple 7y ago
Context is not a requirement of the actual act of composition, though; that's what I'm trying to help you understand. Context might be why you might compose two things in a specific way, or why you might restrict composition between given things, but the act of composition itself is not tied to those specific requirements. In the functional realm: passing a function and list into a map function should work for any function and any list; map needn't care whether or not that function actually is applicable to that list (if it ain't, then that's the function's problem, not map's). Same deal for the "composeObject" function (if Foo and Bar shouldn't be composed, then don't try to compose Foo and Bar), and same deal for the compose procedure (if step1 and step6 shouldn't be composed, then don't try to compose step1 and step6).
> The composition of step1 and step6 is illegal because it doesn't make sense
It doesn't make sense to you. The computer doesn't care whether or not it makes sense to you. The computer only cares that it's able to pop two subroutine pointers and push one to a new subroutine that JMPs/CALLs to those popped pointers. The computer's gonna try to go to the store and eat a chicken, because that's what it's been told to do. To the computer, that makes perfect sense, because everything's subroutines and words, the chicken and the store and the going and the eating just being data to be pushed and popped.
You're welcome to write subroutines that actually validate your ideas of sensibility before proceeding to actually compose the subroutines they're popping off the stack, and there are indeed languages that help you with that, but the computer is still fully capable of composing things regardless of whether or not you think they should be composed.
----
To humor your argument, though:
composeFooAndBar(first: Class<Foo>, second: Class<Bar>) {
third = new Class
third._methods = first._methods.merge(second._methods)
return third
}
FooBar = composeFooAndBar(Foo, Bar)
foobar = new FooBar
foobar.hi; foobar.bye # "howdy" then "adios"
FooBaz = composeFooAndBar(Foo, Baz) # Yay! Our sensibilities are enforced!
- crimsonalucard 7y ago>Context is not a requirement of the actual act of composition, though; that's what I'm trying to help you understand. Context might be why you might compose two things in a specific way, or why you might restrict composition between given things, but the act of composition itself is not tied to those specific requirements. In the functional realm: passing a function and list into a map function should work for any function and any list; map needn't care whether or not that function actually is applicable to that list (if it ain't, then that's the function's problem, not map's). Same deal for the "composeObject" function (if Foo and Bar shouldn't be composed, then don't try to compose Foo and Bar), and same deal for the compose procedure (if step1 and step6 shouldn't be composed, then don't try to compose step1 and step6). Context matters. This is what the type system is for, the type system makes it so the computer will also know what can compose with what. You claimed the computer doesn't care, the type system proves you wrong. >but the computer is still fully capable of composing things regardless of whether or not you think they should be composed. Composition as a concept itself doesn't exist as a command on the instruction set level. It's a higher level concept. Another higher level concept is teaching the computer about the domain by feeding it into the type system. Why are you talking about the low level inability of a computer to comprehend the domain when on that same level the computer is unable to compose things as well. The topic of conversation is about a higher level of logic. Types and composition allow your computer to know about domain and compose. >To humor your argument, though: Remember way back when i defined composition as a universal function? Meaning that the compose function should be able to compose ANYTHING. Not just a Foo and Bar and your arbitrary composition rule. For example it should be able to compose a ONE and a TWO into a THREE as well. That's my arbitrary composition rule for addition. Your example fails to prove anything nor humor anyone.
- yellowapple 7y ago> This is what the type system is for, the type system makes it so the computer will also know what can compose with what. But the computer doesn't have to know that in order for you to be able to compose things. You can compose things without a type system (or more precisely: with a type system where the only actual type is a machine-width word). You just have to take care to make sure the result makes sense in your domain (which a type system helps automate for you). That is: the type system is not the thing that lets you do composition. It's just the thing that lets you constrain what can be composed. In the pseudo-Forth example, you take two arbitrary procedures that pop arguments and push results, and you get back an arbitrary procedure that pops arguments and pushes results. Your ONE and TWO are now a THREE. They're fully interchangeable components (remember my suggestion of that word?). Whether you should interchange them is another story entirely, but you can if you want to. That's composition. > Remember way back when i defined composition as a universal function? Meaning that the compose function should be able to compose ANYTHING. That's exactly what the previous OO example did, but you complained that being able to compose anything somehow doesn't count as composition because it's not restrictive enough. Now you're complaining that not being able to compose anything somehow doesn't count as composition. Let's dig into what you might mean by that, though - specifically with your "arbitrary composition rule for addition". How would you go about implementing add(Store, Chicken) (or Store + Chicken)? What would that mean? What would your THREE actually be after adding your ONE and TWO? The normal answer would be using a bit of that "mortar and rebar" to tell the computer how to add a Chicken to a Store to get some other type (a Popeyes, perhaps?), e.g. by defining methods to polymorphically perform that addition, but it seems like you ain't exactly satisfied by that answer. Unfortunately, the type system alone doesn't really help you much here; just because the computer knows what a Chicken and a Store and a Popeyes is doesn't mean it knows how to add a Chicken and a Store to get a Popeyes. If you object to the "nonsensical" results of trying to add a Store to a Chicken, then you can't get around having to define specific implementations of that composition between a Store and a Chicken. Maybe you can cheat through it a bit by subclassing them from a common ancestor or having them both implement an interface and then add against that ancestor/interface, but that just punts the problem.
- 7y ago