[erlang-questions] Erlang/OTP 20.0, atoms and function names with Unicode

derek denc716@REDACTED
Thu May 4 23:23:28 CEST 2017


like this gist?
https://gist.github.com/anonymous/2e8babd349167a49eb6f6d55ec0505c9

On Thu, May 4, 2017 at 3:36 AM José Valim <jose.valim@REDACTED>
wrote:

> I have rebuilt Erlang from master and both the test and the code snippet
> you sent by e-mail works. In order to discard any encoding issue in the
> process, can you please push your code snippets to a repository?
>
>
>
> *José Valim*
> www.plataformatec.com.br
> Skype: jv.ptec
> Founder and Director of R&D
>
> On Thu, May 4, 2017 at 8:04 AM, José Valim <
> jose.valim@REDACTED> wrote:
>
>> Hi derek,
>>
>> I have sent a PR that improves the coverage around this feature:
>> https://github.com/erlang/otp/pull/1439
>>
>> The test currently passes on an old master reference. I will rebuild my
>> development VM from master and follow up.
>>
>>
>>
>> *José Valim*
>> www.plataformatec.com.br
>> Skype: jv.ptec
>> Founder and Director of R&D
>>
>> On Thu, May 4, 2017 at 1:11 AM, derek <denc716@REDACTED> wrote:
>>
>>>
>>> I found this feature from some of the merged PRs of Erlang/OTP 20
>>>
>>>
>>> https://github.com/erlang/otp/blob/master/lib/stdlib/doc/src/unicode_usage.xml#L66-L71
>>> https://github.com/erlang/otp/pulls?q=unicode
>>>
>>> > Erlang/OTP 20.0, atoms and function can contain Unicode characters
>>>
>>> so I built the binary from git checked out source code (from revision
>>> efcb91bce) and play with it: it seems in escript interpreting mode it
>>> works, but compiling mode still has errors:
>>>
>>> ➸ cat ./hello.erl
>>> #!/usr/bin/env escript
>>> %% -*- coding: utf-8 -*-
>>> %%! +pc unicode
>>>
>>> -module(hello).
>>> %-mode(compile).
>>> -export([main/1, 'hello_юникод_世界'/0]).
>>>
>>> main(_) ->
>>>   % io:format("~p~n", [{io:printable_range(), io:getopts()}]),
>>>   % 'hello_'(),
>>>   io:setopts([{encoding,unicode}]),
>>>   % io:format("~p~n", [{io:printable_range(), io:getopts()}]),
>>>   'hello_юникод_世界'(),
>>>   io:format("~tp~n", [{"Hello, 世界, юникод"}]).
>>>
>>> 'hello_юникод_世界'() ->
>>>   io:format("~tp~n", [{'hello_юникод', <<"Hello, 世界; юникод"/utf8>>,
>>> "Hello, 世界; юникод"}]).
>>>
>>> ➸ erlang20 ./hello.erl
>>> {'hello_юникод',<<"Hello, 世界; юникод"/utf8>>,"Hello, 世界; юникод"}
>>> {"Hello, 世界, юникод"}
>>>
>>> If I uncomment the "-mode(compile)." line, it just runs into compilation
>>> error (same as below shell compilation errors)
>>>
>>> Or in the Erlang shell, trying to compile it just failed: (I have to
>>> remove (or comment out) the first "#!/usr/bin/env escript" line)
>>>
>>> ➸ erlang20
>>> Erlang/OTP 20 [DEVELOPMENT] [erts-9.0] [source-efcb91bce] [64-bit]
>>> [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]
>>>
>>> Eshell V9.0  (abort with ^G)
>>> 1> c(hello).
>>> hello.erl: internal error in beam_asm;
>>> crash reason: badarg
>>>
>>>   in function  list_to_binary/1
>>>      called as list_to_binary([[5,104,101,108,108,111],
>>>   [4,109,97,105,110],
>>>   [2,105,111],
>>>   [7,115,101,116,111,112,116,115],
>>>   [6,102,111,114,109,97,116],
>>>
>>> [15,104,101,108,108,111,95,1102,1085,1080,1082,1086,1076,95,19990,30028],
>>>   "\vmodule_info",
>>>   [6,101,114,108,97,110,103],
>>>   [15,103,101,116,95,109,111,100,117,108,101,95,105,110,102,111]])
>>>   in call from beam_asm:chunk/3 (beam_asm.erl, line 213)
>>>   in call from beam_asm:build_file/8 (beam_asm.erl, line 97)
>>>   in call from beam_asm:module/4 (beam_asm.erl, line 31)
>>>   in call from compile:beam_asm/1 (compile.erl, line 1370)
>>>   in call from compile:'-internal_comp/4-anonymous-1-'/2 (compile.erl,
>>> line 329)
>>>   in call from compile:fold_comp/3 (compile.erl, line 355)
>>>   in call from compile:internal_comp/4 (compile.erl, line 339)
>>> error
>>> 2>
>>>
>>> I have looked up in many of the commit messages, still not seeing a good
>>> example of how to use unicode in function names? Could some developer
>>> behind this feature give more examples?
>>>
>>> https://github.com/erlang/otp/blame/master/lib/stdlib/doc/src/unicode_usage.xml#L66-L71
>>>
>>> _______________________________________________
>>> 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/20170504/dbbbbe7e/attachment.htm>


More information about the erlang-questions mailing list