You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/07/28 18:23:01 UTC

[jira] [Commented] (THRIFT-4269) Don't append '.' to Erlang namespace if it ends in '_'.

    [ https://issues.apache.org/jira/browse/THRIFT-4269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16105435#comment-16105435 ] 

ASF GitHub Bot commented on THRIFT-4269:
----------------------------------------

GitHub user dhull opened a pull request:

    https://github.com/apache/thrift/pull/1319

    THRIFT-4269: Don't append '.' to Erlang namespace if it ends in '_'.

    THRIFT-3834 added support for namespaces to the Erlang code generator. However, that support uses a `.` between the namespace name and the type name.  This is inconvenient because, although `.` is a valid character in an Erlang atom, atoms that contain `.` must be quoted.  This means that a struct named MyStruct in the namespace NS will generate a record named `'NS.MyStruct'`.  The rules for naming atoms in Erlang are:
    
    > Atoms begin with a lower-case letter, and may contain alphanumeric characters, underscores (_) or at-signs (@). Alternatively atoms can be specified by enclosing them in single quotes ('), necessary when they start with an uppercase character or contain characters other than underscores and at-signs.
    
    This pull request changes the Erlang code generator so that if an Erlang namespace ends in a `_` then no `.` is added between the namespace and the struct name when creating the record. This preserves the current behavior unless the namespace ends is a `_`, but allow users to override the normal behavior by adding an explicit `_` to the end of their namespace declarations.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dhull/thrift thrift-4269-erlang-namespace-dot-optional

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/1319.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1319
    
----
commit 453f45725e3fd474ff08c0633d8902bf1a8358f4
Author: David Hull <da...@openx.com>
Date:   2017-07-28T00:09:42Z

    THRIFT-4269: Add Erlang namespace test using ConstantsDemo.thrift.

commit 50fade0cf7cd9b922d5d87c76d21afc9ce62ee15
Author: David Hull <da...@openx.com>
Date:   2017-07-27T23:26:55Z

    THRIFT-4269: Don't append '.' to Erlang namespace if it ends in '_'.
    
    THRIFT-3834 added support for namespaces to the Erlang code
    generator. However, that support uses a '.' between the namespace name
    and the type name.  This is inconvenient because, although '.' is a
    valid character in an Erlang atom, atoms that contain '.' must be
    quoted.  This means that a struct named MyStruct in the namespace NS
    will generate a record named 'NS.MyStruct'.  The rules for naming
    atoms in Erlang are:
    
        Atoms begin with a lower-case letter, and may contain alphanumeric
        characters, underscores (_) or at-signs (@). Alternatively atoms
        can be specified by enclosing them in single quotes ('), necessary
        when they start with an uppercase character or contain characters
        other than underscores and at-signs.
    
    This commit changes the Erlang code generator so that if an Erlang
    namespace ends in a '_' then no '.' is added between the namespace and
    the struct name when creating the record. This preserves the current
    behavior unless the namespace ends is a '_', but allow users to
    override the normal behavior by adding an explicit '_' to the end of
    their namespace declarations.

----


> Don't append '.' to Erlang namespace if it ends in '_'.
> -------------------------------------------------------
>
>                 Key: THRIFT-4269
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4269
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Erlang - Compiler
>    Affects Versions: 0.10.0
>            Reporter: David Hull
>            Priority: Minor
>
> THRIFT-3834 added support for namespaces to the Erlang code generator. However, that support uses a {{.}} between the namespace name and the type name. This is inconvenient because, although {{.}} is a valid character in an Erlang atom, atoms that contain {{.}} must be quoted. This means that a struct named {{MyStruct}} in the namespace {{NS}} will cause a record named {{'NS.MyStruct'}} to be generated. Here are the rules for naming atoms in Erlang:
> bq. Atoms begin with a lower-case letter, and may contain alphanumeric characters, underscores (_) or at-signs (@). Alternatively atoms can be specified by enclosing them in single quotes ('), necessary when they start with an uppercase character or contain characters other than underscores and at-signs.
> I propose that if an Erlang namespace ends in a {{\_}} that no {{.}} be added between the namespace and the struct name when creating the record. This will preserve the current behavior unless the namespace ends is a {{\_}}, but allow users to override the normal behavior by adding an explicit {{\_}} to the end of their namespace declarations.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)