[erlang-questions] literal character syntax

Fred Hebert mononcqc@REDACTED
Wed May 14 16:15:37 CEST 2014


I think the argument here is specifically about whitespace characters.

For example, using:

starts_with([$  | _]) -> space;
starts_with([$	 | _]) -> tab;
starts_with([$
 |_]) -> newline.

Is currently allowed, but it is arguably clearer to use:

starts_with([$\s | _]) -> space;
starts_with([$\t | _]) -> tab.
starts_with([$\n | _]) -> newline.

Vlad here recommends deprecating the former case, while recommending the
latter form.

I would tend to agree for the sake of readability, but would like a
regular deprecation cycle with warnings explaining the recommended
changes ("The $<space> form is being deprecated, replace with $\s" or
something).

Regards,
Fred.

On 05/14, Sean Cribbs wrote:
> They are incredibly useful in pattern-matching simple string arguments. e.g.
> 
> case erlang:system_info(version) of
>     [$5, $., $1, $0 | _ ] -> ok;
>     _ -> fail
> end
> 
> 
> On Wed, May 14, 2014 at 4:28 AM, Vlad Dumitrescu <vladdu55@REDACTED> wrote:
> 
> > Hi!
> >
> > I would like to make a suggestion regarding the accepted literal
> > characters syntax. At the moment, any character following a $ is accepted
> > as itself. I find it very confusing when these characters are whitespace or
> > control chars and my suggestion is to refuse these literals. Most of them
> > have escaped representations and the others should be written as integers
> > anyway.
> >
> > What do you think? Is anyone using these in a meaningful way?
> >
> > best regards,
> > Vlad
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> >
> >
> 
> 
> -- 
> Sean Cribbs <sean@REDACTED>
> Software Engineer
> Basho Technologies, Inc.
> http://basho.com/

> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list