Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compile time virtual machine/stack machine

26 views
Skip to first unread message

bitrex

unread,
Feb 7, 2019, 5:33:56 PM2/7/19
to
Has anyone ever made a fashion of stack machine that executes
at compile time, using C++ metaprogramming?

This would be a runtime example of the type of simple machine I'm
talking about:

<http://gameprogrammingpatterns.com/bytecode.html>

Example application would be on say a resource-limited embedded
processor controlling a graphic display where a "script" for the
animations, etc, a script sort of like Macromedia/Adobe Director, is
written by a (possibly not C++-saavy coder) using a stack-machine-type
language like Forth. And then where that VM code is evaluated at compile
time, and itself "compiles" into a sequence of more primitive C++ API
calls which are then statically linked into the main code to produce the
result.

Another example might be an implementation of Logo:

https://en.wikipedia.org/wiki/Logo_(programming_language)

where the Logo-language-stuff is evaluated by the compiler and at
run-time the actual image is generated by a sequence of primitive
drawLine calls to a low-level API.

Öö Tiib

unread,
Feb 8, 2019, 4:19:36 AM2/8/19
to
The stateful metaprogramming has been forbidden with verdict "arcane".
https://wg21.cmeerw.net/cwg/msg5556
With gcc and clang it doesn't work anymore and with msvc it never did.
Research something else. ;)

bitrex

unread,
Feb 8, 2019, 11:27:09 AM2/8/19
to
I see. Yeah you would need metaprogramming state to at least construct
the equivalent of a program counter.

0 new messages