Thursday, February 7, 2019

Digest for comp.lang.c++@googlegroups.com - 13 updates in 5 topics

bitrex <user@example.net>: Feb 07 05:33PM -0500

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.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Feb 07 09:06PM +0100

Specifically, I wonder how will one achieve something like this with
modules?
 
 
-------------------------------------------------------------------------------
#pragma once // Source encoding: UTF-8 with BOM (π is a lowercase
Greek "pi").
 
namespace cppx
{
namespace best_effort
{
#ifdef CPPX_ASCII_PLEASE
constexpr auto& left_quote_str = "\"";
constexpr auto& right_quote_str = "\"";
constexpr auto& bullet_str = "*";
constexpr auto& left_arrow_str = "<-";
constexpr auto& right_arrow_str = "->";
#else
constexpr auto& left_quote_str = """;
constexpr auto& right_quote_str = """;
constexpr auto& bullet_str = "•";
constexpr auto& left_arrow_str = "←";
constexpr auto& right_arrow_str = "→";

No comments: