manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.42k stars 125 forks source link

Properties: type-safe, now with values too! #583

Closed avertx closed 6 months ago

avertx commented 6 months ago

Type-safe Properties with library-parsed/cast value type safety

CSV module provides sampling...

Properties could have a hint somewhere to allow type-safe values. Maybe as simple as @Extending existing string with .parseLong() and such?

rsmckinney commented 6 months ago

CSV module provides sampling...

Right, however CSV models a record type with multiple rows of data bundled with it. The multiple rows are what makes sampling possible to deduce aspects of the record type etc. In contrast, properties model a hierarchy, typically to reflect a configuration, which represents a single "row" or instance of hierarchical data, as a consequence it is difficult to infer type information from a single properties file. If multiple files of the same hierarchy are available in the same environment, then sampling may become a possibility. Unfortunately, the vast majority of properties files are typically used as single configurations per environment.

Properties could have a hint somewhere...

While that's possible, it's not practical from manifold's perspective because it entails either changing the properties file format or adding metadata as data, which pollutes the data in the file, particularly when used outside of manifold. Basically, if anyone were okay with either or both of these changes, they could just as well change the configuration medium from properties to something more richly typed like JSON Schema, which manifold already supports.