Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1029579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:33:57+00:00 2026-05-16T12:33:57+00:00

I’ve been thinking about doing my own language (practicality: it’s a thought experiment). One

  • 0

I’ve been thinking about doing my own language (practicality: it’s a thought experiment). One of the ideas I came up with is in-language semantic variation. You’d write essentially semantic regular expressions, to be replaced with equivalent code. You can see this in a somewhat less direct form in D- they have string mixins that convert to D code. Except I was going to do them implicitly, and in a more circular fashion.

Right now, I originate from C++. So if you consider:

string a, b, c, d;
// do stuff
a = b + c + d;

This code results in various temporaries. Even if you have rvalue references, you will create temporaries, they will simply be re-used more efficiently. But they still exist and still waste performance. I was thinking about, in the most simple case, of how these could be eliminated. You could write a semantic regular expression that would convert it into the most optimized form.

string a, b, c, d;
// do stuff
a.resize(b.size() + c.size() + d.size());
a = b; a += c; a += d;

If I implemented std::string, I might be able to write something even faster. The key to this is that they’re implicit – when you use the std::string class, the axioms written by the std::string implementer can affect any std::string code. You could just drop it in to an existing C++ codebase, recompile, and get the fastest string concatenation that your std::string implementer can conceive of for free.

At the moment, the optimizations you can make are limited, because you only have as much context as the language allows you, in this case, operator overloading in C++ only taking two arguments, this and arg. But a semantic reg ex could take virtually all the context you could ever need – since you can dictate what it matches – and even match to language features that don’t exist in the host language. For example, it would be trivial to exchange

string a;
a.size;

for

string a;
a.size();

if you wanted to steal C# properties. You could match class definitions and implement compile or run time reflection, etc.

But, I mean, it could get confusing. If there was a bug, or what was really done behind the scenes didn’t reflect the code that was written, it could be a total bitch to track down, and I’ve not considered how it would be implemented in depth. What do you guys think of my proposed language feature?

Oh man, choosing the right tags. Ummm….

Edit: I also wanted to breach the scope of limits, as regards to one answer I had. The simple fact is that semantic regex has no limits (minus implementation details that may have to be added). For example, you could turn the expression

int i;
cin >> i;
int lols[i];

into

int i;
cin >> i;
std::variable_array<int>(alloca(sizeof(int) * i), i);

The semantics of alloca make manipulation with templates impossible- you have to write a macro if you want the above. In C++03 or C++0x, you cannot encapsulate your own VLAs.

In addition, semantic regexes can match code that doesn’t actually invoke any compile-time work. For example, you could match every member of a class definition and use it to create a reflection system. This is also impossible in C++ to date.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:33:57+00:00Added an answer on May 16, 2026 at 12:33 pm

    If you Google for something like “C++ expression template”, you’ll find that in reality C++ already has pretty similar capabilities. Depending on what you came up with for syntax, your idea might make such code easier to understand (expression templates certainly aren’t trivial) but at least to me it’s not entirely clear that you’re adding much (if anything) in the way of truly new capability.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I am doing a simple coin flipping experiment for class that involves flipping a
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.