solnic changed the topic of #rom-rb to: Ruby Object Mapper | Mailing List: https://groups.google.com/forum/?fromgroups#!forum/rom-rb | Logs: http://irclog.whitequark.org/rom-rb
<mbj> dkubb: Just look at the AST documentation from whitequark/parser.
<dkubb> ahh ok
<mbj> I found it okay to play down the amount of nodes.
<mbj> There is no standaline "FROM" statement in sql.
<mbj> So you dont need a dedicated node.
<dkubb> yeah, I was just thinking maybe there would be a way to use better names so in cases where the position isn't obvious a name would be better
<mbj> dkubb: See emitters, there is a children helper for naming.
<mbj> class MyEmitter
<mbj> handle :select
<dkubb> a from node can contain a name of a table, or an expression that evaluates to rows
<mbj> yeah
<mbj> So you place a node in the position.
<mbj> you got it.
<dkubb> there's no stand-alone group by or having, but order by can appear in other places
<mbj> yeah
<mbj> But ORDER BY cannot exist standalone.
<dkubb> right
<dkubb> ok, so that's the main test then
<dkubb> if it can be stand-alone, then it's named?
<mbj> The rule: "standalone" == "own" node, works pretty well.
<dkubb> ok
<mbj> Yeah
<dkubb> so I'll just have to train my brain to memorize the positional "arguments" to a select
<mbj> name them ;)
<mbj> you'll probably have a context where you can use a children DSL helper like builder.
<snusnu> hey dkubb and mbj
<dkubb> so, in that code, instead of s(:delimited, s(:id, 'name'), s(:id, 'age')) I would write s(:group_by, s(:id, 'name'), s(:id, 'age')) ?
<snusnu> i've started using this snippet a lot: https://gist.github.com/snusnu/8048511
<dkubb> or are you saying name them in the emitter
<mbj> dkubb: Axiom AST => SQL AST will probably have an emitter.
<mbj> dkubb: Emitters MUST not write to a buffer.
<mbj> dkubb: I use the emitter pattern also for preprocessing ASTs.
<mbj> dkubb: look at morpher.
<mbj> snusnu: morpher is going well, begun to add the error tracking for evaluators with tracing.
<mbj> snusnu: once we have this I'll go for 0.1 release soon.
<mbj> snusnu: BTW I also added the concept of transitive and intransitive transforming evalutors.
<mbj> snusnu: Evaluators can be asked if they support transitive properties or not, via the #transitive? predicate.
<mbj> snusnu: Works pretty well. I think I can leave spiking soon.
<mbj> dkubb, snusnu: going to sleep. Cu!
mbj has quit [Quit: leaving]
mbj has joined #rom-rb
<mbj> dkubb: Last note. Positional argument == "many nodes can fit here"
<mbj> *many differend node types
<mbj> have fun, will catch up tomorrow
mbj has quit [Client Quit]
<dkubb> snusnu: that's a nice pattern
<snusnu> dkubb: thinking about extracting it into a gem named lupo
<dkubb> what's that stand for?
<snusnu> dkubb: heh, it basically came to my mind in reference to loop
<snusnu> dkubb: it's a name tho, granted, i've mostly heard it for dogs, heh
<snusnu> dkubb: iterator is free on rubygems too, but i wonder if that's maybe a bit too generic for that little snippet
<dkubb> does it require concord?
<dkubb> yeah, I think that's probably too generic
<snusnu> not really, altho it's slightly less locs without
<snusnu> i'd probably not make it depend on concord tho, equalizer functionality isn't needed
<dkubb> I probably would do it without concord
<snusnu> yeah
<dkubb> I'd only use concord if it saved you lots of cdoe
<snusnu> yeah, for such a tiny gem it's overkill, i use it in *every* project tho, so i have it around anyway
<snusnu> it might be a good fit for the new upcoming microrb
<dkubb> is that going to be a metagem, or just a grouping of small gems?
<snusnu> the latter i suppose, dunno if there'll be a metagem too, for now it's an org only, with no repos ;)
<dkubb> I wish you could setup an org and reference repos in other places
<dkubb> rather than forking
<snusnu> yeah that'd be sweet
<dkubb> guard did that for a while, forking everyone's gems, but I'm not sure how it worked out
<dkubb> I remember going to the original author's repos to find updates because they lagged
<snusnu> yeah, forks are always going to lag, the only proper fix is to support what you suggested, orgs spanning arbitrary projects
<dkubb> that would actually be awesome. people could curate sets of projects under some arbitrary category
<dkubb> you could have an organiztion for jquery repositories for example
<snusnu> dkubb: ^^
<dkubb> one other pattern I've used is: host.instance_exec(@name) do |enumerble|
<dkubb> it cuts out one line of code ;)
<dkubb> although it makes a bigger difference if you've got a couple of ivars you need to set to local vars
<snusnu> dkubb: lol damnit, i forgot .. we ended up with that in anima didnt we
<snusnu> yeah
<dkubb> well, techncially you can do a, b, c = @a, @b, @c
<dkubb> I would probably also prefix the ivar with an underscore
<dkubb> just to make it clear it's not actually a "real" attribute in the instance
<snusnu> dkubb: huh? why? you mean the @name ivar inside the lupo module?
<dkubb> oh wait
<dkubb> nevermind
<dkubb> duh
<dkubb> that always messes me up
<dkubb> it's an instance in the module. forgive me, just got called into work on my day off, so I'm not all here
<snusnu> dkubb: heh no worries, yeah, sometimes those "module classes" are still confusing
<snusnu> dkubb: speaking of useful modules … https://gist.github.com/snusnu/8049410
<snusnu> dkubb: &block is probably not too common to pass to .new tho .. i just sketched it quickly, but you get the idea
lfox has quit [Quit: ZZZzzz…]
snusnu has quit [Quit: Leaving.]
postmodern has quit [Quit: Leaving]
Gibheer has quit [Read error: Connection reset by peer]
Gibheer has joined #rom-rb
jordanyee has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Gibheer has quit [Ping timeout: 240 seconds]
Gibheer has joined #rom-rb
rolfb has joined #rom-rb
jordanyee has joined #rom-rb
postmodern has joined #rom-rb
jordanyee has quit [Client Quit]
zirni has joined #rom-rb
zirni_ has joined #rom-rb
zirni has quit [Ping timeout: 248 seconds]
zirni_ has quit [Client Quit]
postmodern has quit [Quit: Leaving]
CraigBuchek has joined #rom-rb
CraigBuchek has quit [Quit: Leaving.]
snusnu1 has joined #rom-rb
jfredett-w has quit [Ping timeout: 245 seconds]
breakingthings has joined #rom-rb
mbj has joined #rom-rb
<snusnu1> yo mbj
snusnu1 has quit [Quit: Leaving.]
snusnu has joined #rom-rb
CraigBuchek has joined #rom-rb
<mbj> snusnu: Yeah I saw it.
<mbj> snusnu: Nice!
<mbj> snusnu: Is there a gem release? I'll use it to reduce loc in mutant :D
<snusnu> mbj: no more boilerplate Concord.new and #each definitions
<mbj> snusnu: nice!
<mbj> snusnu: I'd use this one also ;)
<mbj> snusnu: Pls release ;)
<snusnu> hehe
<mbj> snusnu: I have a method object like this for YEARS in my code.
<mbj> But did not extracted it.
<mbj> snusnu: nice, thx!
snusnu has quit [Quit: Leaving.]
rolfb has quit [Quit: Linkinus - http://linkinus.com]
snusnu has joined #rom-rb
<snusnu> mbj: name ideas for the MethodObject gem?
<mbj> snusnu: meot
<CraigBuchek> Name idea: objection
<mbj> CraigBuchek: heh, nice one!
<mbj> class Foo
<mbj> include Objection.new(:bar)
<mbj> def bar
<mbj> :baz
<mbj> end
<mbj> end
<mbj> Foo.call # => :baz
<CraigBuchek> Still trying to wrap my head around how it works.
<mbj> CraigBuchek: Its a very simple pattern.
<mbj> CraigBuchek: Just imagine you have to do some complex computation. And you wanna have an inheritance tree to "adjust the computation" in specific ways.
<CraigBuchek> Also not following how including an instance of the class works.
<mbj> class SomeAlgo
<mbj> def initialize(foo, bar)
<mbj> @foo, @bar = foo, bar
<mbj> end
<mbj> def result
<mbj> compute_with @foo, @bar
<mbj> end
<mbj> end
<mbj> I have written this stuff VERY often.
<mbj> Initialize an object with a single query method returing a computed value.
<mbj> To use this thing I had to do:
<mbj> SomeAlgo.new(:state_a, :state_b).result
<mbj> Over the time I created a .call on SomeAlgo like
<mbj> def self.call(*arguments)
<mbj> new(*arguments).result
<mbj> end
<mbj> Than we spotted, hey lots of classes have this .call on singleton, creating an instance and calling a specific method pattern....
<mbj> So we plan to move all this repetition into the following interface:
<mbj> class SomeAlgo
<mbj> include Concord.new(:foo, :bar), MethodObject.new(:result)
<mbj> def result
<CraigBuchek> Yeah. I think I've got the use case. Just not the implementation.
<mbj> still_do_the_same_here
<mbj> end
<mbj> end
<mbj> SomeAlgo.call(....)
<mbj> CraigBuchek: ahh, sorry.
<mbj> I thought both, the implementation and the idea of this class is unknown for you.
<snusnu> CraigBuchek: a subclass of class Module is basically a module instance, that can have regular state attached like any class, and then be included
<CraigBuchek> Not familiar with include Xyz.new
<snusnu> CraigBuchek: so it allows you to "customize" a module
<CraigBuchek> Yeah. I've seen that pattern a few times (in ROM, mostly) and love it. Just don't understand …. oh…
<CraigBuchek> So the instance is also a module… Nice trick.
<CraigBuchek> Been wanting to write up a blog entry about the pattern.
<snusnu> yeah, module is a "regular" class, and instances of it are modules
<CraigBuchek> Not sure I like the include Xyz.new as much as something like include Virtus::AR.model though.
<mbj> CraigBuchek: And instance methods defined on the regular class dont get mixed into a host class.
<mbj> class MyMod < Module
<snusnu> yeah, with lupo i went for more explicit "factories" like Lupo.enumerable and Lupo.collection
<mbj> def something
<mbj> end
<mbj> end
<mbj> class Foo
<mbj> include MyMod.new
<mbj> end
<mbj> Foo#something will NOT exist.
<snusnu> CraigBuchek: can you explain your thoughts behind "objection"? to me, it sounds like objecting to something, i.e. not agreeing with it? (i'm no native english speaker tho)
<CraigBuchek> LOL. No, it was just a play on the word object.
skade has joined #rom-rb
<snusnu> heh ok
jordanyee has joined #rom-rb
<snusnu> thinking about "procto"
<snusnu> lol
<CraigBuchek> That's definitely why it popped into my head. I think I also liked that it ends in "ion", sounding like injection and similar words. I kinda also like the irony of the meaning not really applying.
<snusnu> hehe, good points
<CraigBuchek> But I can understand that the negative literal meaning could be a problem.
<snusnu> i actually like procto, it's a "reverse" to_proc, kinda applies, but still sounds funny and meaningless :)
<CraigBuchek> Sounds too much like proctologist to me.
<mbj> snusnu: callable ?
<CraigBuchek> Which could be a little joke though.
<snusnu> hah now what does that mean? (lmgtfm)
<CraigBuchek> Or proctor.
<snusnu> proctor is taken
<CraigBuchek> Figured.
<mbj> free
<mbj> class Foo
<mbj> include Callable.new(:bar)
<mbj> end
<CraigBuchek> Callable seems too generic.
<mbj> yeah
<snusnu> lol now i know what proctology means :D
<mbj> callable_singleton :D
<CraigBuchek> But I'm not going to paint the shed, so I shouldn't have a vote against. ;)
<mbj> snusnu: callable_singleton?
<mbj> its very exact
<snusnu> no underscores allowed. period
<mbj> hah
<mbj> snusnu: abstract_type ;)
<snusnu> not mine
<snusnu> lol
<mbj> snusnu: descendants_tracker
<snusnu> not mine
<mbj> snusnu: rom-mapper :D
<snusnu> not mine
<snusnu> lol
<mbj> trollol ;
<snusnu> hahahaha
<snusnu> i knew it
<snusnu> :p
<mbj> datamapper_on_rails3
<snusnu> damnit
<mbj> snusnu: rule of thumb with naming.
<mbj> snusnu: Pick one that fits. Rename later if you find a better one.
<mbj> snusnu: Go for callable_singletion.
<CraigBuchek> Hey, maybe proctology is a good name. You're pulling something out of somewhere....
<snusnu> takes away the fun, no, i don't want that .. if you want that, you write and release it
<snusnu> :p
<snusnu> CraigBuchek: right! :)
<mbj> snusnu: I thought you are the SRP gem buttler ;)
<mbj> snusnu: And I can request any 100 loc gem from you :D
<snusnu> hehe
<snusnu> what can i say, i like procto
<mbj> It reads like a superhero name :D
<snusnu> for example, yes
<mbj> inline with inflecto
<snusnu> and lupo
<mbj> yeah
<mbj> We need more gems ending in o
<mbj> mutato :D
<snusnu> hehe
<mbj> unparso
<mbj> requesto
<mbj> respondo
<mbj> substationo
skade has quit [Quit: Computer has gone to sleep.]
<mbj> ducktrapo
<mbj> morpho
<snusnu> morpho would be srsly cool tho
<mbj> hehe
<mbj> yeah
<mbj> We can still rename.
<mbj> I like morpo also.
<mbj> morpo vs inflecto
<mbj> *morpho vs inflecto
<mbj> All that superhero namings must sound "heroical" when $a vs $b :D
<snusnu> hehe
<snusnu> ok then, i'm going to write procto now, bbiab
<mbj> snusnu: +1
<mbj> snusnu: BTW do you like of having morpher evaluators support #transitive? property
<mbj> I think its perfect to know if you define a mapper that is NOT transitive.
<mbj> There are several transformations you can do that are not inversible.
<mbj> And I'll still allow to define them.
<snusnu> so transitive? => true means there's no automatic inverse ?
<mbj> snusnu: other way round.
<mbj> snusnu: transitive? => true implies evaluator.inverse.call(evaluator.call(object)) == object
<mbj> snusnu: with transitive? => false this is not an invariant.
<mbj> snusnu: Maybe I transitive is not the correct word.
<mbj> snusnu: Thought about bijective for a moment.
<CraigBuchek> So the gem is basically implementing the Method Object pattern.
<mbj> CraigBuchek: That code I showed belongs to another gem, morpher.
<CraigBuchek> So do you guys have a name for the pattern of passing parameters to the include?
<CraigBuchek> I like "Parameterized Module Inclusion", although I think I've seen another name or 2.
<mbj> CraigBuchek: currently we only call it module subclass.
<mbj> CraigBuchek: Statefull module include, might be a better name.
<CraigBuchek> Dynamic module inclusion.
<mbj> nah, somehow I imagine modules could be included automagically
<mbj> autoload for module inclusion or something.
<mbj> *when reading dynamic module inclusion
<snusnu> CraigBuchek: custom module instance?
<CraigBuchek> Yeah, that's not bad either.
<mbj> You could also customize your module like this:
<mbj> Module.new.instance_variable_set(:@foo, "Bar")
<mbj> Does not imply a subclass with behavior.
<mbj> module subclass instance
<CraigBuchek> Yeah, and there was the one that was basically include Virtus.model(options). And Virtus.model uses a builder to dynamically build the module. I love that.
<snusnu> CraigBuchek, mbj: wdyt about include Procto.call(:print)
<snusnu> include Procto.call(:print) # => needs #print
<snusnu> include Procto.call # => needs #call
<CraigBuchek> Hmm.
<mbj> snusnu thats REALLY nice!
mbj has quit [Quit: leaving]
<CraigBuchek> Should it be calls instead of call there?
<snusnu> hm, that kinda implies many calls to be included
<CraigBuchek> No, I was trying to imply that it calls "print".
<CraigBuchek> Ie. that it will call print.
<snusnu> yeah i thought so, to me that doesn't fit with the include tho
<snusnu> i think of it: ok, i include a procto call
<CraigBuchek> So the nice thing about Virtus.model (and I could easily be mistaking Virtus for something else here) is that "model" describes what I want the object to be. By saying include Virtus.model, I'm saying that this thing is a Virtus model. Just like when I say include Enumerable, I'm saying that this thing is enumerable.
<snusnu> CraigBuchek: btw, a rather nice and complete usage of a custom module builder is in https://github.com/mbj/anima/blob/master/lib/anima.rb
<CraigBuchek> I don't think there's a way to make English express that here though.
<CraigBuchek> I did just think of something really evil though. What if you added self.method_missing to MethodObject, and let it be called with include MethodObject.whatever, and then it news up with whatever method name method_missing got. (I did say it was evil!)
<CraigBuchek> Here's a thought (not necessrily a good one): include Callable.method(:print)
snusnu has quit [Quit: Leaving.]
snusnu has joined #rom-rb
jfredett-w has joined #rom-rb
<snusnu> CraigBuchek: sry, was on the phone earlier and then jumped directly into the code
<snusnu> CraigBuchek: the method_missing idea is somewhat nice! Callable.method(:print) wouldn't work tho, as #method is provided by ruby already
<snusnu> dkubb: ^^
breakingthings has quit []
breakingthings has joined #rom-rb
<dkubb> snusnu: you may want to check the english definition: http://www.thefreedictionary.com/procto- ;)
snusnu has quit [Quit: Leaving.]
snusnu has joined #rom-rb
<snusnu> dkubb: lol
<dkubb> hmm, looks like heroku is going to maintain 1.8.7 and 1.9.2 security patches
snusnu has quit [Quit: Leaving.]
lfox has joined #rom-rb
snusnu has joined #rom-rb
snusnu has quit [Ping timeout: 246 seconds]
cored has joined #rom-rb
mbj has joined #rom-rb
mbj has quit [Ping timeout: 246 seconds]
mbj has joined #rom-rb
postmodern has joined #rom-rb
snusnu has joined #rom-rb
<dkubb> mbj: do you think all the strings in here https://github.com/dkubb/sql/blob/master/lib/sql/generator/emitter/binary_operation.rb#L13-L19 should be moved to the constants file?
<dkubb> I just wondered if maybe it was better to centralize all the possible string in one place
mbj has quit [Ping timeout: 240 seconds]
mbj has joined #rom-rb
mbj has quit [Ping timeout: 246 seconds]
mbj has joined #rom-rb
<mbj> dkubb, snusnu: back
mbj has quit [Ping timeout: 240 seconds]
mbj has joined #rom-rb
lfox has quit [Quit: ZZZzzz…]
<mbj> dkubb, snusnu: I'm back
<mbj> dkubb: I have such a constants.rb file also in emitter.
<mbj> dkubb: Makes lots of sense.
<mbj> dkubb: Not only for speed, also for having a single source of truth.
<mbj> snusnu: mhwahaha we have procto on rubygems....
<mbj> snusnu: nice work!
<mbj> snusnu: BTW dont forget to add the others to owners on rubyforge.
<mbj> snusnu: I think its good to have multiple people that can release updates in case of version conflicts.
<mbj> snusnu: We should share push rights, just as we did with the other support stuff.
CraigBuchek has quit [Quit: Leaving.]
jgaskins has quit [Quit: Leaving]
<dkubb> mbj: yeah, I went with that approach. it's nice to have one place to see everything at a glance
<dkubb> I'm going to look for any other strings like the ones I showed earlier and move them into constants.rb
<dkubb> mbj: as always, if you see me doing anything weird in sql.rb please lmk
<dkubb> right now i'm just trying to get the same basic expressions as in axiom-sql-generator
<dkubb> mbj: also, when you get a chance would you mind commenting on: https://github.com/dkubb/sql/pull/8
cored has quit [Ping timeout: 250 seconds]
cored has joined #rom-rb
lfox has joined #rom-rb
mbj has quit [Ping timeout: 250 seconds]
breakingthings has quit []
mbj has joined #rom-rb
mbj_ has joined #rom-rb
mbj has quit [Read error: Connection reset by peer]
<mbj_> dkubb: I just commented on the PR.
skade has joined #rom-rb
mbj_ is now known as mbj
jordanyee has quit [Quit: Textual IRC Client: www.textualapp.com]
jordanyee has joined #rom-rb
mbj has quit [Read error: Connection reset by peer]
skade has quit [Quit: Textual IRC Client: www.textualapp.com]
mbj has joined #rom-rb
<mbj> I more and more feel ruby should have optimal static typing.
<mbj> def(Integer foo)
<mbj> when called from dynamic code a runtime type check would be made.
<mbj> When called form static code like
<mbj> def foo(Integer foo)
<mbj> foo(foo)
<mbj> end
<mbj> there wouldnt be a type check at runtime.
<mbj> I'd expect only 1-5% of my could would need static types.
<mbj> *optimal => optional ;)
lfox has quit [Quit: ZZZzzz…]
<snusnu> mbj: i've added you as gem owner to lupo and procto
<mbj> snusnu: thx