ugly and/or useless features in the language.

sighoya sighoya at gmail.com
Sun May 23 09:58:56 UTC 2021


On Sunday, 23 May 2021 at 08:35:31 UTC, Tony wrote:
> Why is metaprogramming added features better than the same 
> features added in the language? One is standard between 
> entities, the other is not.

Some points:
- Some features aren't general enough to be added as builtin but 
make sense to have them in libraries
- library features could be extended and modified arbitrarily 
which isn't possible with builtin features
- if better library features are found they can simply be removed 
from the library while probably breaking the library, it doesn't 
break the language which is much of a bigger problem
- most problems with builtin features is that they overwrite 
grammar for a certain scope a.k.a syntactic sugar leading to 
learn new rules/a new language (see C++) while a general 
framework would reuse the same grammar again and again providing 
uniformity
- most builtin features are added incrementally to a language in 
order to be predictable/implementable, unfortunately this leads 
often to fragmentation because later with enough practical 
experience you see another approach to solve the problem, making 
this approach available may overlap with the feature you already 
added, i.e. it solves to some extent the same problems but with 
other tradeoffs making it hard to choose the right approach.

There are also disadvantages, among them the locality/globaility 
problem: Implementing features via macros may need context 
information and other existing features need to be informed of 
the new feature in order to handle it correctly which would 
require many hooks which can't be solved solely with macros. We 
would require massive compiler reflection support for this. 
Further, it is unclear how it would behave at boundaries where 
hooks would collide with each other.




More information about the Digitalmars-d-learn mailing list