[erlang-questions] literal character syntax

Vlad Dumitrescu vladdu55@REDACTED
Wed May 14 17:31:33 CEST 2014


Hi!

Of course there should be a proper deprecation cycle, it's a braking
change.

I've been looking very briefly at where would these checks be made and I'd
say that it probably should be in the preprocessor. However, the scanner
already interprets the literals and the only way to know how the value was
specified in the source is by having the scanner return the text and it's
not a very good idea to always do that (memory usage could increase
dramatically).

A solution would be to let the character tokens always include the text,
but this potentially breaks code that assumes there is no text attribute if
it wasn't requested. On the other hand, the attributes are specified as an
opaque data type and should be accessed with attribute_info and token_info,
so maybe we could get away with that? If yes, I will start working on it.
If not, I welcome other suggestions.

regards,
Vlad



On Wed, May 14, 2014 at 4:32 PM, Björn-Egil Dahlberg <egil@REDACTED>wrote:

> On 2014-05-14 16:15, Fred Hebert wrote:
>
>> 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).
>>
> I like this proposal.
>
> I don't know how fast we could remove $ , $    , etc (earliest 19?) but we
> could certainly emit irritating deprecation warnings that make people want
> to fix their code.
>
> // Björn-Egil
>
>
>
>
>> 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
>>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140514/1f1d0494/attachment.htm>


More information about the erlang-questions mailing list