Skip to content

Conditional based Macros #449

@antfu

Description

@antfu

Describe your issue/suggestions

There are conditional inclusions in C++ looks like this

#if defined(CREDIT)
    credit();
#elif defined(DEBIT)
    debit();
#else
    printerror();
#endif

I think this is extremely helpful for Wenyan when it comes to stdlib. For example, we can have (I keep the same syntax in C++ for better demonstration, we may discuss the syntax later)

今有一術。名之曰「左移」。欲行是術。必先得二數。曰「甲」。曰「乙」。乃行是術曰。
#if TARGET_LANG = py
	施「(lambda x: lambda y : x<<y)」於「甲」。於「乙」。名之曰「丙」。乃得「丙」。
#elif TARGET_LANG = js
	施「(x=>y=>(x<<y))」於「甲」。於「乙」。名之曰「丙」。乃得「丙」。
#else
	吾有一言。曰「「NOT SUPPORTED」」。書之。
#endif
是謂「左移」之術也。

This makes the stdlib more maintainable and also opens more possibilities for different use cases.

Checklist

Before you create this issue, Please make sure ALL the following items are checked

  • If this is a feature request, it's NOT listed Here
  • If this is a bug report, it's NOT listed Here

Metadata

Metadata

Assignees

No one assigned

    Labels

    syntaxSuggestions to improve the syntax

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions