Re:Show HN: The Silicon C++14 Web Framework
by matt42 on Monday January 19, 2015 @07:20AM
(#8911560)
You are right. I'll make it clear in the README.
The preprocessing can be easy done by hand for those who want to skip the use of the preprocessor, it is actually pretty simple:
[...]
@test
[...]
is equivalent to:
iod_define_symbol(test, _test)
[...]
s::_test
[...]
Their is 3 reason for implementation of the @ syntax:
- Not having to pre-declare all the symbols.
- Replacing s::_ by @
- Suggesting a new simple but powerful feature to
the teams writing clang++ and g++.
And yes, silicon needs generic lambda function from C++14 . But this is less a problem since this is already in g++, clang++, and soon in the visual studio c++ compiler.
Re:Show HN: The Silicon C++14 Web Framework
by Someone on Monday January 19, 2015 @04:45PM
(#8914305)
I'm too lazy/not interested enough in this to give it a try, and am not sure at all that they are powerful enough to do what you want, but have you considered using user-defined literals? The way I understand these work,
"test"@
could return an object that allows one to write "test"@("hello"!)
The constructors called could, of course, also link that object in a global store.
Re:Show HN: The Silicon C++14 Web Framework
by acron0 on Monday January 19, 2015 @09:20AM
(#8911986)
Could it not have been expressed with just a macro?
EDIT: Down votes? lol
Re:Show HN: The Silicon C++14 Web Framework
by matt42 on Monday January 19, 2015 @09:28AM
(#8912026)
Here is the tranformation done by the preprocessor: https://gist.github.com/matt-42/a53cc0b0a8d8f1cf673f
It would be really convenient to have it done by the C preprocessor, but it seems impossible to me to get it with macro only. Am I wrong?
Re:Show HN: The Silicon C++14 Web Framework
by bratsche on Monday January 19, 2015 @09:57AM
(#8912142)
It seems like you could do something like:
#define IOD_SYM(name) iod_define_symbol(name, _##name);
#define S(name) s::_##name;
Then use S(test) instead of @test and any files that need these symbols defined could just have IOD_SYM(test) at the top or something.
Re:Show HN: The Silicon C++14 Web Framework
by matt42 on Monday January 19, 2015 @10:08AM
(#8912191)
#define S(name) is a bit dangerous. It would affect any C/C++ function called S.
Re:Show HN: The Silicon C++14 Web Framework
by pfultz2 on Monday January 19, 2015 @12:22PM
(#8912832)
Actually using [ZLang](https://github.com/pfultz2/ZLang), you could define them like this:
#define IOD_DEFINE_SYMBOL(name) iod_define_symbol(name, _##name)
#define IOD_S(name) s::_##name
#define ZLANG_iod_define (IOD_DEFINE_SYMBOL)
#define ZLANG_iod_s (IOD_S)
And then compiling with `-DZLANG_NS=iod` you can call it like this: // Define symbols
$(define hello)
$(define message)
auto hello_api = make_api(
// The hello world procedure.
$(s hello) = [] () { return D($(s message) = "Hello world."); }
);
Also, ZLang can be supported without a need for a dependency on ZLang.
The same comments apply to a lesser extent to the C++14 requirement- does your framework really benefit from using C++14 features over say C++11 ? Again I would make this clear at the top of the README.