How can I substitute the type of an argument received via a
varadic template?
For example say I want to generalise this scenario:
auto myConverterFunction1(bool arg1, bool arg2, ubyte arg3, int
arg4)
{
return targetFunction(cast(ubyte)arg1, cast(ubyte)arg2, arg3,
arg4);
}
So I'll have
On Tuesday, 2 August 2016 at 07:24:28 UTC, Saurabh Das wrote:
How can I substitute the type of an argument received via a
varadic template?
For example say I want to generalise this scenario:
auto myConverterFunction1(bool arg1, bool arg2, ubyte arg3, int
arg4)
{
return targetFunction(ca
On Tuesday, 2 August 2016 at 08:16:48 UTC, Sean Campbell wrote:
On Tuesday, 2 August 2016 at 07:24:28 UTC, Saurabh Das wrote:
[...]
Just of the top of my head, using ugly string mixins, this:
auto myConverterFunc(Args...)(Args args)
{
string genCode()
{
string code
On Tuesday, 2 August 2016 at 08:20:22 UTC, Saurabh Das wrote:
On Tuesday, 2 August 2016 at 08:16:48 UTC, Sean Campbell wrote:
[...]
Thanks. Yes that is one approach. I figured out another
approach that seems decent:
auto targetFunctionProxy(Args...)(Args args)
{
import std.meta;
ret
On Tuesday, 2 August 2016 at 08:22:15 UTC, Saurabh Das wrote:
On Tuesday, 2 August 2016 at 08:20:22 UTC, Saurabh Das wrote:
On Tuesday, 2 August 2016 at 08:16:48 UTC, Sean Campbell wrote:
[...]
Thanks. Yes that is one approach. I figured out another
approach that seems decent:
auto targetF
On 8/1/16 9:24 PM, Rufus Smith wrote:
Can one add code that executes before the GC and any memory is normally
allocated(even static) and after all of it was suppose to be released?
Of course! You just have to modify druntime :)
One thing you can do instead is compile without a D main function,
So basically I get the error "function button(lua_State* L) is
not callable using argument types ()" whenever I try to
lua_register a function.
```
lua_register(L,"button",button);
```
but whenever I use the function pointer I get the error
"lua_register is not callable using argument types (lu
I've tried to write an 'assert function' in D, one that doesn't
trigger the 'function must return a value or assert' error.
Basically something like:
Never neverReturns() { assert(0); }
or
@noreturn auto neverReturns() { assert(0); }
and
int tryMe(bool f) {
if(f) return 42;
else nev
On 8/2/16 11:09 AM, Enamex wrote:
I've tried to write an 'assert function' in D, one that doesn't trigger
the 'function must return a value or assert' error.
Basically something like:
Never neverReturns() { assert(0); }
or
@noreturn auto neverReturns() { assert(0); }
and
int tryMe(bool f) {
On Tuesday, 2 August 2016 at 15:18:31 UTC, Steven Schveighoffer
wrote:
What's wrong with assert(0) that you need to have a wrapper
function for it?
while this is a legitimate question, the comipler's inability to
infer "noreturn" still drives me mad. but if compiler will
suddenly be able to i
On Tuesday, 2 August 2016 at 15:18:31 UTC, Steven Schveighoffer
wrote:
What's wrong with assert(0) that you need to have a wrapper
function for it?
-Steve
Nothing wrong exactly. I just wanted some descriptive terms to
use in some places. Like "unreachable()" or "unimplemented()".
To be cle
On 8/2/16 11:34 AM, Enamex wrote:
On Tuesday, 2 August 2016 at 15:18:31 UTC, Steven Schveighoffer wrote:
What's wrong with assert(0) that you need to have a wrapper function
for it?
-Steve
Nothing wrong exactly. I just wanted some descriptive terms to use in
some places. Like "unreachable()"
On Tuesday, 2 August 2016 at 11:37:05 UTC, Steven Schveighoffer
wrote:
On 8/1/16 9:24 PM, Rufus Smith wrote:
Can one add code that executes before the GC and any memory is
normally
allocated(even static) and after all of it was suppose to be
released?
Of course! You just have to modify drunti
On Tuesday, 2 August 2016 at 16:21:07 UTC, Rufus Smith wrote:
How does one use C main? extern C?
extern(C) int main()
should do it
I see that there are ports of go compiler on ev3dev (ARM, debian
based) for controlling the EV3 lego mindstorm robot.
(http://www.ev3dev.org/docs/libraries/)
Is there a port of a D compiler for ARM? How about libraries? I
need a basic file IO and console IO for controlling the robot.
Thanks
On Tuesday, 2 August 2016 at 14:23:55 UTC, Jack wrote:
So basically I get the error "function button(lua_State* L) is
not callable using argument types ()" whenever I try to
lua_register a function.
```
lua_register(L,"button",button);
```
but whenever I use the function pointer I get the error
On Tuesday, 2 August 2016 at 16:30:08 UTC, Adam D. Ruppe wrote:
On Tuesday, 2 August 2016 at 16:21:07 UTC, Rufus Smith wrote:
How does one use C main? extern C?
extern(C) int main()
should do it
It doesn't seem to be that easy!
https://wiki.dlang.org/Runtime_internals
If I do this then I
On Tuesday, 2 August 2016 at 17:04:08 UTC, Rufus Smith wrote:
It doesn't seem to be that easy!
_d_run_main is extern(C), not just extern. Then your code should
work.
You can also simplify more:
---
import std.stdio;
import core.runtime;
extern(C) int main() {
rt_init();
wri
On Tuesday, 2 August 2016 at 17:23:57 UTC, Adam D. Ruppe wrote:
_d_run_main is extern(C), not just extern. Then your code
should work.
Also, you don't actually have to rt_init and rt_term if you do
_d_run_main because it does it for you...
On 8/2/16 1:04 PM, Rufus Smith wrote:
On Tuesday, 2 August 2016 at 16:30:08 UTC, Adam D. Ruppe wrote:
On Tuesday, 2 August 2016 at 16:21:07 UTC, Rufus Smith wrote:
How does one use C main? extern C?
extern(C) int main()
should do it
It doesn't seem to be that easy!
https://wiki.dlang.org/
On 8/2/16 1:26 PM, Adam D. Ruppe wrote:
On Tuesday, 2 August 2016 at 17:23:57 UTC, Adam D. Ruppe wrote:
_d_run_main is extern(C), not just extern. Then your code should work.
Also, you don't actually have to rt_init and rt_term if you do
_d_run_main because it does it for you...
I don't thin
Hi,
I'm trying to use the module core.checkedint, but I have a
problem and I don't know if it is a bug or me.
This simple program compiles well in debug mode with dmd, but
give me an error when I compile in release mode: Error: function
core.checkedint.muls cannot inline function
import co
On Sunday, 31 July 2016 at 18:57:50 UTC, Jack Stouffer wrote:
Next question: what's the fastest hashing implementation that
will provide the least collisions? Is there a hash
implementation that's perfered for AAs?
I've heard that FNV-1a is a decent general-purpose option, and
it's fairly str
On Tuesday, 2 August 2016 at 17:25:21 UTC, Steven Schveighoffer
wrote:
On 8/2/16 1:04 PM, Rufus Smith wrote:
On Tuesday, 2 August 2016 at 16:30:08 UTC, Adam D. Ruppe wrote:
On Tuesday, 2 August 2016 at 16:21:07 UTC, Rufus Smith wrote:
How does one use C main? extern C?
extern(C) int main()
On 8/2/16 2:09 PM, Etranger wrote:
Hi,
I'm trying to use the module core.checkedint, but I have a problem and I
don't know if it is a bug or me.
This simple program compiles well in debug mode with dmd, but give me an
error when I compile in release mode: Error: function
core.checkedint.muls ca
On 8/2/16 2:25 PM, Rufus Smith wrote:
So, something funky is going on. Any ideas?
phobos is not being resolved.
I don't use visualD, so I'm not sure what the issue is, it's probably a
compiler or linker ordering issue.
-Steve
On Tuesday, 2 August 2016 at 18:34:49 UTC, Steven Schveighoffer
wrote:
On 8/2/16 2:25 PM, Rufus Smith wrote:
So, something funky is going on. Any ideas?
phobos is not being resolved.
I don't use visualD, so I'm not sure what the issue is, it's
probably a compiler or linker ordering issue.
On Tuesday, 2 August 2016 at 18:32:42 UTC, Steven Schveighoffer
wrote:
On 8/2/16 2:09 PM, Etranger wrote:
Hi,
I'm trying to use the module core.checkedint, but I have a
problem and I
don't know if it is a bug or me.
This simple program compiles well in debug mode with dmd, but
give me an
e
On Tuesday, 2 August 2016 at 20:28:51 UTC, Rufus Smith wrote:
On Tuesday, 2 August 2016 at 18:34:49 UTC, Steven Schveighoffer
wrote:
On 8/2/16 2:25 PM, Rufus Smith wrote:
So, something funky is going on. Any ideas?
phobos is not being resolved.
I don't use visualD, so I'm not sure what the
A hack is to create the gc code you in a function want to call,
say does the "gc" opEquals. Then cast that function to a nogc
version by first casting to a void*. This way you can call gc
code from nogc code, by bypassing the compiler's ability to
check. It will obviously break your code if you
Hello,
I am currently trying to improve the TOML library of:
https://github.com/iccodegr/toml.d
I get a really weird error:
Error: function main.TOMLValue.opAssign is not callable because
it is annotated with @disable
I have tested this with dmd 2.071.1 and 2.068.0.
Here is the code to re
On Tuesday, 2 August 2016 at 16:44:39 UTC, Mike Parker wrote:
On Tuesday, 2 August 2016 at 14:23:55 UTC, Jack wrote:
[...]
lua_register takes function pointers that in the form of
lua_CFunction, an alias you can find declared in
derelict.lua.types [1]. As you'll see there, it is declared to
winmain.d(40): Error: found 'while' when expecting ';' following
statement
winmain.d(40): Error: unexpected ( in declarator
winmain.d(40): Error: basic type expected, not &
winmain.d(40): Error: found '&' when expecting ')'
winmain.d(40): Error: found 'msg' when expecting ')'
winmain.d(40): Error
It's nice to be able to pass delegates and functions as callbacks.
A nice feature is something like
R foo(R,Args...)(R function(Args) callback, Args args) { return
callback(args); }
There are two problems with this.
One is that type deduction doesn't work. I have to explicitly
specify the t
On 03/08/2016 4:31 AM, Sai wrote:
I see that there are ports of go compiler on ev3dev (ARM, debian based)
for controlling the EV3 lego mindstorm robot.
(http://www.ev3dev.org/docs/libraries/)
Is there a port of a D compiler for ARM? How about libraries? I need a
basic file IO and console IO for
On Tuesday, 2 August 2016 at 16:31:30 UTC, Sai wrote:
I see that there are ports of go compiler on ev3dev (ARM,
debian based) for controlling the EV3 lego mindstorm robot.
(http://www.ev3dev.org/docs/libraries/)
Is there a port of a D compiler for ARM? How about libraries? I
need a basic file
On 08/02/2016 06:56 PM, Mark J Twain wrote:
winmain.d(40): Error: found 'while' when expecting ';' following statement
winmain.d(40): Error: unexpected ( in declarator
winmain.d(40): Error: basic type expected, not &
winmain.d(40): Error: found '&' when expecting ')'
winmain.d(40): Error: found '
37 matches
Mail list logo