You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Filipe David Manana <fd...@apache.org> on 2010/09/27 19:47:08 UTC

adding new macro to couch_db.hrl

Hi,

I'm getting tired of typing couch_util:get_value(......). It also
consumes too much horizontal space. It's probably the most used
function from couch_util.
I'm thinking of adding a new macro in couch_db.hrl, like:

-define(value(Key, List), couch_util:get_value(Key, List)).

-define(value(Key, List, Default), couch_util:get_value(Key, List, Default)).

Or maybe naming the macro just "get".

Anyone against it?


cheers

-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: adding new macro to couch_db.hrl

Posted by Paul Davis <pa...@gmail.com>.
On Mon, Sep 27, 2010 at 1:47 PM, Filipe David Manana
<fd...@apache.org> wrote:
> Hi,
>
> I'm getting tired of typing couch_util:get_value(......). It also
> consumes too much horizontal space. It's probably the most used
> function from couch_util.
> I'm thinking of adding a new macro in couch_db.hrl, like:
>
> -define(value(Key, List), couch_util:get_value(Key, List)).
>
> -define(value(Key, List, Default), couch_util:get_value(Key, List, Default)).
>
> Or maybe naming the macro just "get".
>
> Anyone against it?
>
>
> cheers
>
> --
> Filipe David Manana,
> fdmanana@gmail.com, fdmanana@apache.org
>
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."
>

I'd vote for value or getval. I'm a bit hesitant about get because of
the overloading of the get bif.

Paul

Re: adding new macro to couch_db.hrl

Posted by Filipe David Manana <fd...@apache.org>.
Unfortunately I'll have to revert the commits.

R13B03 and bellow don't allow for macros with same name but different
arities - compilation fails.
I guess we'll have to use import where needed.

On Mon, Sep 27, 2010 at 7:59 PM, Filipe David Manana
<fd...@apache.org> wrote:
> On Mon, Sep 27, 2010 at 7:46 PM, Damien Katz <da...@apache.org> wrote:
>> I wouldn't mind it being ?get(...) as required by a macro. Also, I think it could be an import statement in couch_db.hrl, so it's automatic for all including files.
>
> couch_util includes couch_db.hrl so we get a compile error.
>
>>
>> -Damien
>>
>>
>> On Sep 27, 2010, at 11:06 AM, Filipe David Manana wrote:
>>
>>> On Mon, Sep 27, 2010 at 7:04 PM, Adam Kocoloski <ko...@apache.org> wrote:
>>>> I don't like "get" because it clashes with the auto-imported erlang:get (for the process dictionary).
>>>>
>>>> Any reason to prefer a macro over an -import statement?
>>>
>>> Just to avoid doing the import everywhere and I still consider
>>> get_value too long :P
>>>
>>>>
>>>> Adam
>>>>
>>>> On Sep 27, 2010, at 1:47 PM, Filipe David Manana wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I'm getting tired of typing couch_util:get_value(......). It also
>>>>> consumes too much horizontal space. It's probably the most used
>>>>> function from couch_util.
>>>>> I'm thinking of adding a new macro in couch_db.hrl, like:
>>>>>
>>>>> -define(value(Key, List), couch_util:get_value(Key, List)).
>>>>>
>>>>> -define(value(Key, List, Default), couch_util:get_value(Key, List, Default)).
>>>>>
>>>>> Or maybe naming the macro just "get".
>>>>>
>>>>> Anyone against it?
>>>>>
>>>>>
>>>>> cheers
>>>>>
>>>>> --
>>>>> Filipe David Manana,
>>>>> fdmanana@gmail.com, fdmanana@apache.org
>>>>>
>>>>> "Reasonable men adapt themselves to the world.
>>>>>  Unreasonable men adapt the world to themselves.
>>>>>  That's why all progress depends on unreasonable men."
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Filipe David Manana,
>>> fdmanana@gmail.com, fdmanana@apache.org
>>>
>>> "Reasonable men adapt themselves to the world.
>>>  Unreasonable men adapt the world to themselves.
>>>  That's why all progress depends on unreasonable men."
>>
>>
>
>
>
> --
> Filipe David Manana,
> fdmanana@gmail.com, fdmanana@apache.org
>
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: adding new macro to couch_db.hrl

Posted by Filipe David Manana <fd...@apache.org>.
On Mon, Sep 27, 2010 at 7:46 PM, Damien Katz <da...@apache.org> wrote:
> I wouldn't mind it being ?get(...) as required by a macro. Also, I think it could be an import statement in couch_db.hrl, so it's automatic for all including files.

couch_util includes couch_db.hrl so we get a compile error.

>
> -Damien
>
>
> On Sep 27, 2010, at 11:06 AM, Filipe David Manana wrote:
>
>> On Mon, Sep 27, 2010 at 7:04 PM, Adam Kocoloski <ko...@apache.org> wrote:
>>> I don't like "get" because it clashes with the auto-imported erlang:get (for the process dictionary).
>>>
>>> Any reason to prefer a macro over an -import statement?
>>
>> Just to avoid doing the import everywhere and I still consider
>> get_value too long :P
>>
>>>
>>> Adam
>>>
>>> On Sep 27, 2010, at 1:47 PM, Filipe David Manana wrote:
>>>
>>>> Hi,
>>>>
>>>> I'm getting tired of typing couch_util:get_value(......). It also
>>>> consumes too much horizontal space. It's probably the most used
>>>> function from couch_util.
>>>> I'm thinking of adding a new macro in couch_db.hrl, like:
>>>>
>>>> -define(value(Key, List), couch_util:get_value(Key, List)).
>>>>
>>>> -define(value(Key, List, Default), couch_util:get_value(Key, List, Default)).
>>>>
>>>> Or maybe naming the macro just "get".
>>>>
>>>> Anyone against it?
>>>>
>>>>
>>>> cheers
>>>>
>>>> --
>>>> Filipe David Manana,
>>>> fdmanana@gmail.com, fdmanana@apache.org
>>>>
>>>> "Reasonable men adapt themselves to the world.
>>>>  Unreasonable men adapt the world to themselves.
>>>>  That's why all progress depends on unreasonable men."
>>>
>>>
>>
>>
>>
>> --
>> Filipe David Manana,
>> fdmanana@gmail.com, fdmanana@apache.org
>>
>> "Reasonable men adapt themselves to the world.
>>  Unreasonable men adapt the world to themselves.
>>  That's why all progress depends on unreasonable men."
>
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: adding new macro to couch_db.hrl

Posted by Damien Katz <da...@apache.org>.
I wouldn't mind it being ?get(...) as required by a macro. Also, I think it could be an import statement in couch_db.hrl, so it's automatic for all including files.

-Damien


On Sep 27, 2010, at 11:06 AM, Filipe David Manana wrote:

> On Mon, Sep 27, 2010 at 7:04 PM, Adam Kocoloski <ko...@apache.org> wrote:
>> I don't like "get" because it clashes with the auto-imported erlang:get (for the process dictionary).
>> 
>> Any reason to prefer a macro over an -import statement?
> 
> Just to avoid doing the import everywhere and I still consider
> get_value too long :P
> 
>> 
>> Adam
>> 
>> On Sep 27, 2010, at 1:47 PM, Filipe David Manana wrote:
>> 
>>> Hi,
>>> 
>>> I'm getting tired of typing couch_util:get_value(......). It also
>>> consumes too much horizontal space. It's probably the most used
>>> function from couch_util.
>>> I'm thinking of adding a new macro in couch_db.hrl, like:
>>> 
>>> -define(value(Key, List), couch_util:get_value(Key, List)).
>>> 
>>> -define(value(Key, List, Default), couch_util:get_value(Key, List, Default)).
>>> 
>>> Or maybe naming the macro just "get".
>>> 
>>> Anyone against it?
>>> 
>>> 
>>> cheers
>>> 
>>> --
>>> Filipe David Manana,
>>> fdmanana@gmail.com, fdmanana@apache.org
>>> 
>>> "Reasonable men adapt themselves to the world.
>>>  Unreasonable men adapt the world to themselves.
>>>  That's why all progress depends on unreasonable men."
>> 
>> 
> 
> 
> 
> -- 
> Filipe David Manana,
> fdmanana@gmail.com, fdmanana@apache.org
> 
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."


Re: adding new macro to couch_db.hrl

Posted by Robert Newson <ro...@gmail.com>.
?getv is what the cool kids would do.

On Mon, Sep 27, 2010 at 7:11 PM, Paul Davis <pa...@gmail.com> wrote:
> On Mon, Sep 27, 2010 at 2:06 PM, Filipe David Manana
> <fd...@apache.org> wrote:
>> On Mon, Sep 27, 2010 at 7:04 PM, Adam Kocoloski <ko...@apache.org> wrote:
>>> I don't like "get" because it clashes with the auto-imported erlang:get (for the process dictionary).
>>>
>>> Any reason to prefer a macro over an -import statement?
>>
>> Just to avoid doing the import everywhere and I still consider
>> get_value too long :P
>>
>>>
>>> Adam
>>>
>>> On Sep 27, 2010, at 1:47 PM, Filipe David Manana wrote:
>>>
>>>> Hi,
>>>>
>>>> I'm getting tired of typing couch_util:get_value(......). It also
>>>> consumes too much horizontal space. It's probably the most used
>>>> function from couch_util.
>>>> I'm thinking of adding a new macro in couch_db.hrl, like:
>>>>
>>>> -define(value(Key, List), couch_util:get_value(Key, List)).
>>>>
>>>> -define(value(Key, List, Default), couch_util:get_value(Key, List, Default)).
>>>>
>>>> Or maybe naming the macro just "get".
>>>>
>>>> Anyone against it?
>>>>
>>>>
>>>> cheers
>>>>
>>>> --
>>>> Filipe David Manana,
>>>> fdmanana@gmail.com, fdmanana@apache.org
>>>>
>>>> "Reasonable men adapt themselves to the world.
>>>>  Unreasonable men adapt the world to themselves.
>>>>  That's why all progress depends on unreasonable men."
>>>
>>>
>>
>>
>>
>> --
>> Filipe David Manana,
>> fdmanana@gmail.com, fdmanana@apache.org
>>
>> "Reasonable men adapt themselves to the world.
>>  Unreasonable men adapt the world to themselves.
>>  That's why all progress depends on unreasonable men."
>>
>
> I'd have to agree with Filipe that I'd probably rather see a macro
> than an import. For some reason or another imports tend to annoy me
> because its a layer of indirection between what's being called.
> Granted, in some of those cases its probably more of a sign that we
> need to break some of the various files into sub modules and what not.
> More at 10.
>

Re: adding new macro to couch_db.hrl

Posted by Paul Davis <pa...@gmail.com>.
On Mon, Sep 27, 2010 at 2:06 PM, Filipe David Manana
<fd...@apache.org> wrote:
> On Mon, Sep 27, 2010 at 7:04 PM, Adam Kocoloski <ko...@apache.org> wrote:
>> I don't like "get" because it clashes with the auto-imported erlang:get (for the process dictionary).
>>
>> Any reason to prefer a macro over an -import statement?
>
> Just to avoid doing the import everywhere and I still consider
> get_value too long :P
>
>>
>> Adam
>>
>> On Sep 27, 2010, at 1:47 PM, Filipe David Manana wrote:
>>
>>> Hi,
>>>
>>> I'm getting tired of typing couch_util:get_value(......). It also
>>> consumes too much horizontal space. It's probably the most used
>>> function from couch_util.
>>> I'm thinking of adding a new macro in couch_db.hrl, like:
>>>
>>> -define(value(Key, List), couch_util:get_value(Key, List)).
>>>
>>> -define(value(Key, List, Default), couch_util:get_value(Key, List, Default)).
>>>
>>> Or maybe naming the macro just "get".
>>>
>>> Anyone against it?
>>>
>>>
>>> cheers
>>>
>>> --
>>> Filipe David Manana,
>>> fdmanana@gmail.com, fdmanana@apache.org
>>>
>>> "Reasonable men adapt themselves to the world.
>>>  Unreasonable men adapt the world to themselves.
>>>  That's why all progress depends on unreasonable men."
>>
>>
>
>
>
> --
> Filipe David Manana,
> fdmanana@gmail.com, fdmanana@apache.org
>
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."
>

I'd have to agree with Filipe that I'd probably rather see a macro
than an import. For some reason or another imports tend to annoy me
because its a layer of indirection between what's being called.
Granted, in some of those cases its probably more of a sign that we
need to break some of the various files into sub modules and what not.
More at 10.

Re: adding new macro to couch_db.hrl

Posted by Filipe David Manana <fd...@apache.org>.
On Mon, Sep 27, 2010 at 7:04 PM, Adam Kocoloski <ko...@apache.org> wrote:
> I don't like "get" because it clashes with the auto-imported erlang:get (for the process dictionary).
>
> Any reason to prefer a macro over an -import statement?

Just to avoid doing the import everywhere and I still consider
get_value too long :P

>
> Adam
>
> On Sep 27, 2010, at 1:47 PM, Filipe David Manana wrote:
>
>> Hi,
>>
>> I'm getting tired of typing couch_util:get_value(......). It also
>> consumes too much horizontal space. It's probably the most used
>> function from couch_util.
>> I'm thinking of adding a new macro in couch_db.hrl, like:
>>
>> -define(value(Key, List), couch_util:get_value(Key, List)).
>>
>> -define(value(Key, List, Default), couch_util:get_value(Key, List, Default)).
>>
>> Or maybe naming the macro just "get".
>>
>> Anyone against it?
>>
>>
>> cheers
>>
>> --
>> Filipe David Manana,
>> fdmanana@gmail.com, fdmanana@apache.org
>>
>> "Reasonable men adapt themselves to the world.
>>  Unreasonable men adapt the world to themselves.
>>  That's why all progress depends on unreasonable men."
>
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Re: adding new macro to couch_db.hrl

Posted by Adam Kocoloski <ko...@apache.org>.
I don't like "get" because it clashes with the auto-imported erlang:get (for the process dictionary).

Any reason to prefer a macro over an -import statement?

Adam

On Sep 27, 2010, at 1:47 PM, Filipe David Manana wrote:

> Hi,
> 
> I'm getting tired of typing couch_util:get_value(......). It also
> consumes too much horizontal space. It's probably the most used
> function from couch_util.
> I'm thinking of adding a new macro in couch_db.hrl, like:
> 
> -define(value(Key, List), couch_util:get_value(Key, List)).
> 
> -define(value(Key, List, Default), couch_util:get_value(Key, List, Default)).
> 
> Or maybe naming the macro just "get".
> 
> Anyone against it?
> 
> 
> cheers
> 
> -- 
> Filipe David Manana,
> fdmanana@gmail.com, fdmanana@apache.org
> 
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."