Mailinglist Archive: yast-devel (144 mails)

< Previous Next >
Re: [yast-devel] Questions about some YCP Equivalents in ruby
On Thu, 29 Aug 2013 16:43:43 +0200
Roman Neuhauser <rneuhauser@xxxxxxx> wrote:

# dmajda@xxxxxxx / 2013-08-29 16:10:14 +0200:
Nothing is black and white and one has to think about degrees of
various positive and negative effects (even of the same kind) in
different situations. In case of hashes with defaults, the positive
effects seems small (a bit of DRY) and the negative ones large (big
surprise at call site).

back to serious mode (on my part).

you said:

To illustrate this, imagine I am debugging something and see code
like this:

result = my_hash["key"]

this is a strawman, nobody sane names their variables "my_hash".
so let's say we have this code:

def parse input, options['strict']).parse(input)

you have no idea what type `options` is, all you know (actually hope
for) is it has a `[](key)` method.

looking at it from the other side, how come you don't mind objects
with `[](key)`? they are *not* Hash, they have all kinds of
"unexpected" behaviors, so really, what's the difference?

From dmajda POV problematic part is when you debug.
It means you add e.g. some inspect call (e.g. in debugger) and see what

h = {|h,k| k }
=> {}

=> :a

=> "{}"

so this part can cause problem. If it somehow say that I am hash with
defined defaults, then it is much better.

To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups