Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 18 2015 10:36
    shterrett opened #1
Stuart Terrett
@shterrett
I PRd two changes to hand and simple-hand that bring the interfaces inline and handle the Ace: SICPDistilled/blackjack#1
thattommyhall
@thattommyhall
Thanks @shterrett, hand is a work-in-progress, I might have to redact it eventually as I kind of want to see if people can move to a new representaion w/o many (ideally any) changes
Stuart Terrett
@shterrett
They've got to meet somewhere; if you want to hand me a totally different data representation, I'll need to write an interface for each one and swap those in. The question is where to draw the line of abstraction, and it seems to me that having all representations of hand obey a contract is a reasonable expectation. That way the hand can be implemented however it wants, but it agrees to yield {:suite X, :rank Y}
thattommyhall
@thattommyhall
I totally agree, not saying ive solved it.
Interesting that in SICP you have one way of doing data abstraction because they teach you it vs in the escher eg doing pattern matching and using perhaps records
thattommyhall
@thattommyhall
I like that I can swap out the clj vector in my escher for Zach Telmans tuple thing
SICP has all the get-* etc whereas we have destructuring via keyword access or positional. Its a lovely tension. What kind of abstraction do I want?
Stuart Terrett
@shterrett
Yeah - that's true. The vector and the tuple both adhere to the "positional destructing" interface. You can totally imagine also writing a get-value for each representation of card, and then using those functions to access the data. A lot of the decision comes down to whether you have control over the data. When I'm writing both sides, I prefer to program against a common interface, and avoid the overhead of dispatch. When I don't have control, or can't satisfy a common interface, I tend to use dispatch, a la SICP, using ruby's interpolation and dynamic calling.