[erlang-questions] Re: erlang improvement - objective c (or smalltalk) syntax

Dale Harvey harveyd@REDACTED
Fri Jun 5 00:07:02 CEST 2009


this is something I have quite liked from python, javascript and
to some end php (using assoc arrays as paramters)

in erlang I do find myself doing

-define(pget(Key, List),
        proplists:get_value(Key, List, undefined)).

default_opts() ->
   [{width, 600}, {height, 600}, {type, "jpg"}].

resize(Image) ->
   resize(Image, default_opts()).

resize(Image, Opts) ->
   %% Just picks userdefined over default
   O = reduce(Opts, default_opts),
   Height  = ?pget(height, Options),
   Width   = ?pget(width,  Options),

quite a lot, its quite a bit of cruft, but I find having optional
+ named parameters more useful than just being able to change
the order.

2009/6/4 Steve Davis <steven.charles.davis@REDACTED>

> Tony -
>
> The sentiment I support.
>
> But I don't think this proposal represents a solution to it, and I
> think your example is incorrect. i.e. I don't think that Joe proposed
> that you need to qualify your arguments every time you call a
> function, but rather only in the signature of the function
> implementation -- which you would still need to consult to find the
> argument order.
>
> regs,
> /s
>
>
> On Jun 4, 3:55 pm, Tony Arcieri <t...@REDACTED> wrote:
> > readable.  Consider:
> >
> > do_something(true, true, 360, 120)
> >
> > versus:
> >
> > do_something(scale:true preserve_aspect:true width:360 height:120)
> >
> > Tony Arcieri
> > medioh.com
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
>


More information about the erlang-questions mailing list