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 <david.h...@openx.com>
Date:   2017-07-28T00:09:42Z

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

commit 50fade0cf7cd9b922d5d87c76d21afc9ce62ee15
Author: David Hull <david.h...@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.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to