metaprogramming


Is D powerful enough for these features?


For the longest time I wanted to design a programming language that married extensibility with efficiency (and safety, ease-of-use, etc.) I recently rediscovered D and I am wondering if D 2.0 is pretty much the language I wanted to make myself. What I love most is the potential of metaprogramming; in theory, could D's traits system enable the following features at compile time?
Run-time reflection: Are the compile-time reflection features sufficient to build a run-time reflection system a la Java/.NET?
Code conversion: Using a metaprogram, create C#/C++/etc. versions of your D program every time you compile it (bonus point if doc comments can be propagated).
Traits. I don't mean the metaprogramming traits built into D, I mean object-oriented traits for class composition. A D program would indicate a set of traits to compose, and a metaprogram would compose them.
Unit inference engine: Given some notation for optionally indicating units, e.g. unit(value), could a D metaprogram examine the following code, infer the correct units, and issue an error message on the last line? (I wrote such a thing for boo so I can assure you this is possible in general, program-wide):
auto mass = kg(2.0);
auto accel = 1.0; // units are strictly optional
auto force = mass*accel;
accel += metresPerSecondSquared(9.81); // units of 'force' and 'accel' are now known
force += pounds(3.0); // unit mismatch detected
Run-time reflection: Are the compile-time reflection features sufficient to build a run-time reflection system a la Java/.NET?
Yes. You can get all the information you need at compile time using __traits and produce the runtime data structures you need for runtime reflection.
Code conversion: Using a metaprogram, create C#/C++/etc. versions of your D program every time you compile it (bonus point if doc comments can be propagated).
No, it simply isn't possible no matter how powerful D is. Some features simply do not transfer over. For example, D has an inline assembler, which is 100% impossible to convert to C#. No language can losslessly convert to all other languages.
Traits. I don't mean the metaprogramming traits built into D, I mean object-oriented traits for class composition. A D program would indicate a set of traits to compose, and a metaprogram would compose them.
You can use template mixins for this, although they don't provide method exclusion.
Unit inference engine: Given some notation for optionally indicating units, e.g. unit(value), could a D metaprogram examine the following code, infer the correct units, and issue an error message on the last line? (I wrote such a thing for boo so I can assure you this is possible in general, program-wide):
Yes, this is straightforward in D. There's at least one implementation already.

Related Links

Programmatically alter Elixir Code
Elixir - How can I unquote an array of functions in my macro?
Nim reflect on type's field types at compile-time
Save variables to file at runtime
In Julia, is it possible to pass values for evaluation in an Expr object without using global variables?
Metaprogramming in Julia — Splice integer into variable name
What's the difference between `use` and `#before_compile`?
How to define functions based on attribute to elixir?
Remove a const qualifier from a variable in D
Meta-modeling crud FROM/JOIN/WHERE statement fragments for higher-level analysis
Elixir: eval'ing code in module context using Code.eval_quoted/3
What is Declarative Meta-Programming?
Reconsolidate protocols in Elixir 1.2 or higher
Inserting an AST into a quote do end block without unquoting it
Transform quoted elixir code to a code string
Pattern matching benchmarking : Compiletime lookup vs Runtime lookup in D

Categories

HOME
facebook-oauth
c99
pagination
pda
pascal
battery
jsf-2.2
nuget
replace
seo
nstableheaderview
teechart
arangodb
speech-synthesis
symmetricds
gource
scrolltop
android-intent
heat
jmp
cfml
solrcloud
drive
undertow
libigl
href
angular-routing
hta
appirater
fractions
rpgle
exchangewebservices
cppreference
ntp
gitlab-api
volatile
quickfixj
clickjacking
android-maps-extensions
sql-delete
imx6
protege4
openerp-7
xcode7.3
release
z-notation
google-data-api
preloader
angular-http
dapper-simplecrud
snapchat
serde
cnc
yii2-api
arq
custom-font
video-conferencing
semantic-logging
boxing
sundials
er-diagram
css-transforms
trigger.io
structuremap4
pocketsphinx-android
flex-monkey
parfor
envi
google-cloud-console
dotnetnuke-7
xdoclet
freepbx
bizagi
phpwebsocket
libav
findfirst
state-restoration
character-replacement
oracle-spatial
rate-limiting
include-guards
iced-coffeescript
uncompress
jsvc
diff3
public-html
filesplitting
sonarqube-5.0
sql-scripts
punycode
teaspoon
build-script
template-deduction
rcaller
dot42
buffering
drupal-nodes
syndicationfeed
hidapi
joomla-template
patricia-trie
zope.interface
usertype
luabind
catransform3d
interprocess
addchild
burndowncharts
lobo-cobra
cuda.net
scrubyt

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App