arrow-julia icon indicating copy to clipboard operation
arrow-julia copied to clipboard

Issues with changes in scopedenums introduced in 2.2.1

Open jonalm opened this issue 3 years ago • 1 comments

Context: The Arrow.jl 2.2.1 release changed the behavior of @scopedenums used in the FlatBuffer submodule, to remedy a type piracy issue. https://github.com/apache/arrow-julia/pull/267

This change introduced a couple of issues:

  1. Enum variabeles were exported from the module which wraps enum values. This pollutes the parent namespace.

https://github.com/apache/arrow-julia/blob/f88a62e0b6458ed6ea0439fc371f2e4ee0e039a7/src/FlatBuffers/FlatBuffers.jl#L148

Suggested fix: do not export the enum values by removing the above line

  1. The name of the module which wraps the the enum gets renamed with a trailing s or es

https://github.com/apache/arrow-julia/blob/f88a62e0b6458ed6ea0439fc371f2e4ee0e039a7/src/FlatBuffers/FlatBuffers.jl#L125

This is not ideal as the scoped enums often correspond to enums which are named and defined in a FlatBuffer schema file. Having custom rules to rename these names are confusing, and the renaming functionality must be shared by code generating functionality.

Suggested fix: Let the wrapping module share name with the enum name (as used in the flatbuffer schema), and let the primitive type (which lives inside that module) have the same name with a leading underscore. Accessing the enum values would thereby feel the same to the end user as before the 2.2.1 change (before 2.21 it was calling getproperty on an exported primitive type, with the proposed change one would access the a constant value inside a module).

jonalm avatar Mar 17 '22 21:03 jonalm

@NHDaly

jonalm avatar Mar 17 '22 22:03 jonalm