On Thursday, 5 June 2014 at 06:58:50 UTC, Timothee Cour via
Digitalmars-d-learn wrote:
Is there a way to do this?
import std.algorithm;
auto fun(T)(T a){return a;}
template fun2(T){auto fun2(T a){return fun(a);}}//OK but heavy
syntax and
cannot be nested inside test()
void main(){
//alias
ok I remembered we can use std.typetuple.Alias for that.
On Wed, Jun 4, 2014 at 11:58 PM, Timothee Cour
wrote:
> Is there a way to do this?
>
> import std.algorithm;
>
> auto fun(T)(T a){return a;}
>
> template fun2(T){auto fun2(T a){return fun(a);}}//OK but heavy syntax and
> cannot be nested
On Wednesday, 4 June 2014 at 23:25:13 UTC, cal wrote:
I have the following code (on dpaste,
http://dpaste.dzfl.pl/636c04430a33):
enum : uint { a, b, c }
enum list = [a, b];
void foo(T...)()
{
pragma(msg, T[0].length); // fine
pragma(msg, T[0][0]); // fine
pragma(msg, T[0][1]); //
On 06/05/14 08:58, Timothee Cour via Digitalmars-d-learn wrote:
> Is there a way to do this?
>
> auto fun(T)(T a){return a;}
>
> template fun2(T){auto fun2(T a){return fun(a);}}//OK but heavy syntax and
> cannot be nested inside test()
alias fun2(T) = fun!T;
But this will prevent IFTI, so
> On 06/05/14 08:58, Timothee Cour via Digitalmars-d-learn wrote:
>> //none of those work:
>> //alias fun2=a=>fun(a);
alias fun2=ALIAS!(a=>fun(a));
That 'ALIAS' template will need to be in module scope.
alias ALIAS(alias A) = A;
artur
On 5/31/14, 7:57, ed wrote:
On Saturday, 31 May 2014 at 07:28:32 UTC, Mineko wrote:
So, I've gotten interested in kernel programming in D.. And as much as
I like C/C++, I wanna try innovating, I'm aware that phobos/gc and any
OS-specific issues are going to be a problem, but I'm willing to
imple
On 6/5/14, 6:05, 1100110 wrote:
On 5/31/14, 7:57, ed wrote:
On Saturday, 31 May 2014 at 07:28:32 UTC, Mineko wrote:
So, I've gotten interested in kernel programming in D.. And as much as
I like C/C++, I wanna try innovating, I'm aware that phobos/gc and any
OS-specific issues are going to be a
On Thursday, 5 June 2014 at 11:07:54 UTC, 1100110 wrote:
On 6/5/14, 6:05, 1100110 wrote:
On 5/31/14, 7:57, ed wrote:
On Saturday, 31 May 2014 at 07:28:32 UTC, Mineko wrote:
So, I've gotten interested in kernel programming in D.. And
as much as
I like C/C++, I wanna try innovating, I'm aware th
I've just had the case where after changing the code and running
"$ dub" nothing changed in the output. I couldn't make sense of
it. Then I ran "$ dub --force" and the output was as expected.
Has this happened to anyone. I think I came across this before.
Hi guys!
I have problem with writing to a file.
My function looks like this:
[code]
int game_change_config(string _player_spritesheet, string
_flame_spritesheet) {
string info = _player_spritesheet~"\n"~_flame_spritesheet;
auto config_file = File("Data/config.ini");
config_file.write(in
On Thu, 05 Jun 2014 17:50:37 +, JJDuck wrote:
> let say I have a Linked List(tango) that holds custom class and how do I
> filter the LinkedList to extract the items that I want according to a
> particular field (a integer field) from my custom class?
>
> Is it easier to do it using phobos' A
let say I have a Linked List(tango) that holds custom class and
how do I filter the LinkedList to extract the items that I want
according to a particular field (a integer field) from my custom
class?
Is it easier to do it using phobos' Array?
If it does, care to have an example on Phobos too?
Try to reduce it: remove code from the program piece by piece
until you find a fragment, which causes the problem.
I'm trying to link a simple D static library to C code, but I'm
can't figure out how to do it properly without getting a segfault
when running it.
test.d
---
import std.stdio;
extern(C) void funcD() {
writeln("From D");
}
main.c
---
You need to link the druntime too, I think.
On Thursday, 5 June 2014 at 18:55:13 UTC, Stefan Koch wrote:
You need to link the druntime too, I think.
At which stage? Can you provide a full command? Thanks.
Well, there is a problem with
config_file.write(info);
but when I'm changing it to
write("Data/config.ini", info);
(as it states in http://dlang.org/phobos/std_file.html#.write)
I'm getting an error of conflict between std.stdio.write and
std.file.write. That's why I was using the first line.
You can create a static library from one or more .o files using
ar, if that helps (unless I've failed to understand the
question). "ar r libtest.a test.o" should do the job.
On Thursday, 5 June 2014 at 19:00:24 UTC, George Sapkin wrote:
On Thursday, 5 June 2014 at 18:55:13 UTC, Stefan Koch wrote:
You need to link the druntime too, I think.
At which stage? Can you provide a full command? Thanks.
Err ... I just remeberd linking d with gcc needs a few libs
-lpthrea
config_file needs to be the string
not a struct File
.
In CTFE it seems. Only tested with DMD on Windows though. Is this a
known limitation, or a bug, I couldn't find anything that seemed to
match it in the bugzilla.
import std.array;
struct DataAndView
{
int[] data, view;
this(int x)
{
data = [1, 2, 3, 4,
> enum b = DataAndView(1);
> assert (!sameTail(b.data, b.view));
I suppose it's because enums are manifest constants: the value they
represent is 'copy-pasted' anew everywhere it appears in the code. So
for arrays and associative arrays, it means recreating a new value
each and eve
On Thu, 05 Jun 2014 15:56:00 -0400, Philippe Sigaud via
Digitalmars-d-learn wrote:
enum b = DataAndView(1);
assert (!sameTail(b.data, b.view));
I suppose it's because enums are manifest constants: the value they
represent is 'copy-pasted' anew everywhere it appears in the co
Right now I have:
import file = std.file;
import std.stdio;
int game_change_config(string _player_spritesheet, string
_flame_spritesheet) {
string info = _player_spritesheet~"\n"~_flame_spritesheet;
char[] info_table;
for(int i = 0; i < info.length; i++) {
info_table.length++;
On 06/05/2014 01:39 PM, Konrad wrote:> Right now I have:
>
> import file = std.file;
> import std.stdio;
>
> int game_change_config(string _player_spritesheet, string
> _flame_spritesheet) {
> string info = _player_spritesheet~"\n"~_flame_spritesheet;
> char[] info_table;
> for(int i =
Ok, I have rebuilded whole solution in MSVS (I'm using VisualD
plugin) and everything started to work with my previously pasted
code.
@Ali, thank you for advise with concatenation, I haven't thought
about that.
Also thank you to all of you, guys, all that you wrote was very
helpfull.
Best
On Thursday, 5 June 2014 at 22:22:16 UTC, Chris Williams wrote:
If I wanted to allocate memory for a class and then call its
constructor as two separate steps, while still having the
object be managed by the garbage collector, is there any way to
do that?
Check out std.conv.emplace
http://dl
If I wanted to allocate memory for a class and then call its
constructor as two separate steps, while still having the object
be managed by the garbage collector, is there any way to do that?
I believe that I've figured out a way to accomplish the first
step, but not the second.
import std.s
On Thursday, 5 June 2014 at 22:25:03 UTC, Adam D. Ruppe wrote:
On Thursday, 5 June 2014 at 22:22:16 UTC, Chris Williams wrote:
If I wanted to allocate memory for a class and then call its
constructor as two separate steps, while still having the
object be managed by the garbage collector, is th
I'm having a very difficult time figuring out exactly how to do
this. I've compiled my D code into a .obj file with dmd, but I
don't know what C compiler I should use (or if it makes any
difference). I've attempted to use MinGW gcc, which spits out .o
files, and Visual Studio, which does... someth
Mark Isaacson:
My attempts to have either the MinGW linker or the Visual Studio
linker accept my D .objs have all failed.
Try using the dmc compiler for the C code.
Bye,
bearophile
On Thursday, 5 June 2014 at 22:59:48 UTC, bearophile wrote:
Mark Isaacson:
My attempts to have either the MinGW linker or the Visual
Studio
linker accept my D .objs have all failed.
Try using the dmc compiler for the C code.
Bye,
bearophile
I'd considered that, but in the long term that w
On 06/05/2014 03:47 PM, Chris Williams wrote:
On Thursday, 5 June 2014 at 22:25:03 UTC, Adam D. Ruppe wrote:
On Thursday, 5 June 2014 at 22:22:16 UTC, Chris Williams wrote:
If I wanted to allocate memory for a class and then call its
constructor as two separate steps, while still having the obj
On Thursday, 5 June 2014 at 07:19:07 UTC, timotheecour wrote:
ok I remembered we can use std.typetuple.Alias for that.
Or std.functional.unaryFun.
Still unresolved, but a thought:
I decided to take a step back and try to link with C on Linux
first. I found out that if I did the linking step with dmd things
worked, but not with gcc. The reason then became apparent: dmd
knows to pass druntime and phobos and all of that stuff to the
linker. Ru
On Thursday, 5 June 2014 at 19:10:17 UTC, Dave Wilson wrote:
You can create a static library from one or more .o files using
ar, if that helps (unless I've failed to understand the
question). "ar r libtest.a test.o" should do the job.
I don't have trouble creating a static library with dmd, I
On Thursday, 5 June 2014 at 19:14:34 UTC, Stefan Koch wrote:
On Thursday, 5 June 2014 at 19:00:24 UTC, George Sapkin wrote:
On Thursday, 5 June 2014 at 18:55:13 UTC, Stefan Koch wrote:
You need to link the druntime too, I think.
At which stage? Can you provide a full command? Thanks.
Err ..
On Thursday, 5 June 2014 at 19:14:34 UTC, Stefan Koch wrote:
On Thursday, 5 June 2014 at 19:00:24 UTC, George Sapkin wrote:
On Thursday, 5 June 2014 at 18:55:13 UTC, Stefan Koch wrote:
You need to link the druntime too, I think.
At which stage? Can you provide a full command? Thanks.
Err ..
On Thursday, 5 June 2014 at 23:12:56 UTC, Mark Isaacson wrote:
I need to eventually be able to export a
dll that can talk with anything.
how would using dmc conflict with this goal?
dmd/dmc output omf object files, windows infrastructure is all
coff object files. linux/mingw/etc are.. someth
I found that if I told dmd rather than gcc to do the linking that
everything just magically worked.
In other words:
gcc -c cstuff.c
dmd -c dstuff.d
dmd cstuff.o dstuff.o
I presume that dmd would be similarly smart with static libraries.
On Friday, 6 June 2014 at 02:01:12 UTC, Mark Isaacson wrote:
I found that if I told dmd rather than gcc to do the linking
that
everything just magically worked.
In other words:
gcc -c cstuff.c
dmd -c dstuff.d
dmd cstuff.o dstuff.o
I presume that dmd would be similarly smart with static
librar
On Thursday, 5 June 2014 at 18:51:25 UTC, George Sapkin wrote:
I'm trying to link a simple D static library to C code, but I'm
can't figure out how to do it properly without getting a
segfault when running it.
try this:
dmd -lib test.d -defaultlib=libphobos2.a -oflibtest.a
gcc main.c libtest.
On Friday, 6 June 2014 at 02:13:08 UTC, Ellery Newcomer wrote:
On Thursday, 5 June 2014 at 18:51:25 UTC, George Sapkin wrote:
I'm trying to link a simple D static library to C code, but
I'm can't figure out how to do it properly without getting a
segfault when running it.
try this:
dmd -lib
On Friday, 6 June 2014 at 02:17:50 UTC, George Sapkin wrote:
On Friday, 6 June 2014 at 02:13:08 UTC, Ellery Newcomer wrote:
On Thursday, 5 June 2014 at 18:51:25 UTC, George Sapkin wrote:
I'm trying to link a simple D static library to C code, but
I'm can't figure out how to do it properly witho
Hello I need to pass a array in D to c. I have edited the code to
the important parts. Normally in C I would just do this:
void myFunction(int *array)
{
}
Then pass it a array of whatever size. However I actually need
the array to be in a struct so...
typedef struct{int* array;} examplestruc
On Friday, 6 June 2014 at 03:40:41 UTC, Harpo wrote:
Hello I need to pass a array in D to c. I have edited the code
to the important parts. Normally in C I would just do this:
void myFunction(int *array)
{
}
Then pass it a array of whatever size. However I actually need
the array to be in a s
sorry thats:
struct examplestruct {int* array;}
int numar[50];
examplestruct parameters;
parameters.array = numuar;
When I do that I get type conflictions. Error: cannot implicitly
convert expression (numar) of type int[50] to int*...
I am not sure what setup I need to have here. Anyone know w
Thanks that was perfect.
Also I am aware of the use of the 64bit numbers. Thank you for
pointing it out though.
48 matches
Mail list logo