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

How can I call .WHY on a subroutine in a class in Perl 6?
Using Roslyn, if I have an IdentifierNameSyntax, can I find the member type it refers to (field, property, method…)
Elixir - Define functions in module by metaprogramming
Disambiguate the various quoting mechanisms in Julia metaprogramming
How to initialize list using macros and then generate same set of functions in 2 different modules?
Type-safe metaprogramming? Using strings to query ceylon.language for meta information?
Interpolating an Expression into an Expression
Loop unrolling? in Julia with metaprogramming
Macro for a function template: escaping issues
Macro that defines macro returning struct constant
Array of Expressions to an Array Definition
Code generation from restricted set of input
System of equations using metaprogramming
How to define a partial copy constructor metaprogramically in Julia?
How to interpolate into a Julia “for” expression?
Sending a keyword list to a macro and using bind_quoted

Categories

HOME
xml
cobalt
formal-languages
jmx
static
solaris
pclxl
replace
newrelic
cq5
web-hosting
crystal-reports-2013
banner
flume
extjs4.2
okhttp
augeas
jsonpath
tput
magnetic-cards
symbol
azure-iot-hub
feathersjs
forgot-password
google-data-studio
database-connection
windows-xp
articulate-storyline
squashfs
ember-cli
postscript
exit
highstock
froala
windows-server-2003
onload
flooding
linked-data
intersystems-cache
user-defined-functions
send
livelink
powershell-ise
activexobject
fiware-cygnus
video-capture
xdocreport
flatmap
css-position
rfc3339
libgphoto2
opennms
facebook-pixel
manova
remedy
appdomain
java-websocket
offline.js
cd-burning
segment-io
dup
avspeechsynthesizer
pre-build-event
character-replacement
themoviedb-api
computer-architecture
rate-limiting
video-player
vacuum
haskell-warp
graphics2d
nsurlsessiondatatask
kubuntu
rapidsvn
viewer
universal-image-loader
ora-00904
malformedurlexception
spring-remoting
renderer
maven-scm
square-bracket
koala
amslidemenu
conditionaltagsupport
bin
artemis
gtm-oauth2
mysql-error-1044
inputmismatchexception
cocoalibspotify-2.0
cffile
chart-director
android-sdk-2.3
device-width
mkv
fragmenttransaction
extconf.rb
wiimote
winmain
cgbitmapcontextcreate
clrstoredprocedure
presentation-layer
load-time
globals
jqueryform
skype4java
leader
appliance
commercial-application
pnrp

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