Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Solidity feature request: macros #2437

Closed
nmushegian opened this issue Jul 10, 2015 · 4 comments
Closed

Solidity feature request: macros #2437

nmushegian opened this issue Jul 10, 2015 · 4 comments

Comments

@nmushegian
Copy link

I want this:

#define PROD false
#define DEFAULT(TYPE, ADDR) #if PROD TYPE(ADDR) #else new TYPE() #endif
#define LOG(what) #if PROD ; #else log(what) #endif

and so on. Don't tell me it's unsafe, I'm gonna use gcc to do it if you don't!

@debris
Copy link
Contributor

debris commented Jul 10, 2015

if macros are considered I would suggest something like rust's macro_rules!

// This is the simplest macro, `say_hello` is the name of the macro
macro_rules! say_hello {
    // `()` indicates that the macro takes no argument
    () => (
        // the macro will expand into the contents of this block
        println!("Hello!");
    )
}

@chriseth
Copy link
Contributor

Yes, I would also prefer a token-based macro system like the one used by rust.

@LefterisJP
Copy link
Contributor

+1 for native macros instead of preprocessor based. Rust's macros are not particularly nice though, we could do better.

@chriseth chriseth changed the title Solc feature request: macros Solidity feature request: macros Jul 14, 2015
@LianaHus
Copy link
Contributor

This issue has been moved to ethereum/solidity repository
ethereum/solidity#10

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants