On Thursday, March 03, 2016 11:42:13 Shriramana Sharma via Digitalmars-d-learn
wrote:
> Hello. I have a function I want to make CTFE-able as a template.
>
> string ta(string s) { return s ~ "1"; }
> template ta(string s) { enum ta = ta(s); }
> void main() { string s = ta!"s"; }
>
> Compiling the
Dne 3.3.2016 v 07:12 Shriramana Sharma via Digitalmars-d-learn napsal(a):
Hello. I have a function I want to make CTFE-able as a template.
string ta(string s) { return s ~ "1"; }
template ta(string s) { enum ta = ta(s); }
void main() { string s = ta!"s"; }
Compiling the above I get the
On 2016-03-02 23:41, Joel wrote:
I don't seem to have a folder 'build' there.
It all seems writable.
Hmm, that's really weird. I guess that's the folder it fails to write.
Is it running as a different user. What if you change the permissions to
allow everything, i.e. "chmod 777 ~/.dub".
Hello. I have a function I want to make CTFE-able as a template.
string ta(string s) { return s ~ "1"; }
template ta(string s) { enum ta = ta(s); }
void main() { string s = ta!"s"; }
Compiling the above I get the errors:
(2): Error: forward reference of variable ta
(3): Error: template instance
Hi,everyone:
I want to access the phone on Windows7,but get a error:
std.file.FileException@std\file.d(3368):\\computer\myPhone\SDCard\myfiles:
0x0041c112
0x0043E601
The error is only on Windows7,it's ok on linux,I doubt it's not a
error with file.d,maybe a
On Wednesday, 2 March 2016 at 08:55:40 UTC, Jacob Carlborg wrote:
On 2016-03-02 05:12, Joel wrote:
Wait a minute, I get this:
Build directory
.dub/build/application-debug-posix.osx-x86_64-dmd_2070-2EBE4466CF46539CC1D524962E530835/
is not writable. Falling back to direct build in the system's
Dne 2.3.2016 v 21:39 Adam D. Ruppe via Digitalmars-d-learn napsal(a):
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
Is it by design or is it a bug?
And, if it is by design, what is the reason for that?
That's by design. It allows you to override names from a template
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
Is it by design or is it a bug?
And, if it is by design, what is the reason for that?
That's by design. It allows you to override names from a template
mixin like inheritance but no runtime cost.
Read my tip of the week here
On Wednesday, 2 March 2016 at 01:14:15 UTC, tsbockman wrote:
On Tuesday, 1 March 2016 at 17:21:16 UTC, David DeWitt wrote:
On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote:
I am aiming to become a hardcore and better coder(quality
code) than you :) Please suggest.
I'd probably skim
On Wednesday, 2 March 2016 at 14:50:15 UTC, Adrian Matoga wrote:
On Wednesday, 2 March 2016 at 14:36:59 UTC, Daniel Kozak wrote:
OK maybe this one:
template AddField(T) {
T b;
this(Args...)(T b, auto ref Args args)
{
this.b = b;
this(args);
}
this(int a) {
On Wednesday, 2 March 2016 at 14:36:59 UTC, Daniel Kozak wrote:
OK maybe this one:
template AddField(T) {
T b;
this(Args...)(T b, auto ref Args args)
{
this.b = b;
this(args);
}
this(int a) {
this.a = a;
}
}
struct Bar {
int a;
mixin
On Wednesday, 2 March 2016 at 13:18:23 UTC, Adrian Matoga wrote:
On Wednesday, 2 March 2016 at 12:48:47 UTC, Daniel Kozak wrote:
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga
wrote:
(...)
You can use string mixins:
template AddField(T) {
enum AddField = T.stringof ~ `
On Wednesday, 2 March 2016 at 09:37:03 UTC, Johan Engelen wrote:
On Wednesday, 2 March 2016 at 07:42:09 UTC, Tamas wrote:
Thanks, fixing this single issue solved the compiler crash too.
Did the compiler crash? Or just exit?
(a crash would still be a bug)
Crashed, just like in the case of
On Wednesday, 2 March 2016 at 08:51:07 UTC, Manuel Maier wrote:
Hi there,
I was wondering why I should ever prefer std.range.lockstep
over std.range.zip. In my (very limited) tests std.range.zip
offered the same functionality as std.range.lockstep, i.e. I
was able to iterate using
On Wednesday, 2 March 2016 at 12:48:47 UTC, Daniel Kozak wrote:
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
(...)
You can use string mixins:
template AddField(T) {
enum AddField = T.stringof ~ ` b;
this(Args...)(` ~ T.stringof ~ ` b, auto ref Args args)
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
I can do this:
struct Foo {
int a;
string b;
this(int a) { this.a = a; }
this(Args...)(string b, auto ref Args args) { this.b = b;
this(args); }
}
unittest {
auto foo1 = Foo(5);
auto
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
I can do this:
struct Foo {
int a;
string b;
this(int a) { this.a = a; }
this(Args...)(string b, auto ref Args args) { this.b = b;
this(args); }
}
unittest {
auto foo1 = Foo(5);
auto
On Wednesday, 2 March 2016 at 10:57:35 UTC, Luis wrote:
Read https://dlang.org/spec/arrays.html#strings and try to use
std.string.toStringz
(http://dlang.org/phobos/std_string.html#.toStringz)
Yes, but that's not what you use when you want to avoid
allocation.
I can do this:
struct Foo {
int a;
string b;
this(int a) { this.a = a; }
this(Args...)(string b, auto ref Args args) { this.b = b;
this(args); }
}
unittest {
auto foo1 = Foo(5);
auto foo2 = Foo("foo", 15);
}
However, the following code is invalid:
On Wednesday, 2 March 2016 at 04:12:13 UTC, Mike Parker wrote:
On Wednesday, 2 March 2016 at 01:39:13 UTC, David G. Maziero
wrote:
Consider the following function:
void RenderText( FontBMP font, int x, int y, const char* text )
{
for( int r=0; text[r]!='\0'; ++r )
{
On Wednesday, 2 March 2016 at 05:04:37 UTC, David G. Maziero
wrote:
I figured out what I wanted. Thanks for your answer Mike, sorry
to bother you though.
[...]
Even null-terminated be sure to profile your loop, for isn't
garanteed to be faster than foreach at all and foreach is
definitely
On Wednesday, 2 March 2016 at 07:42:09 UTC, Tamas wrote:
Thanks, fixing this single issue solved the compiler crash too.
Did the compiler crash? Or just exit?
(a crash would still be a bug)
On 2016-03-02 05:12, Joel wrote:
Wait a minute, I get this:
Build directory
.dub/build/application-debug-posix.osx-x86_64-dmd_2070-2EBE4466CF46539CC1D524962E530835/
is not writable. Falling back to direct build in the system's temp folder.
Is ~/.dub writable by you? What about the sub
Hi there,
I was wondering why I should ever prefer std.range.lockstep over
std.range.zip. In my (very limited) tests std.range.zip offered
the same functionality as std.range.lockstep, i.e. I was able to
iterate using `foreach(key, value; std.range.zip(...)) {}` which,
according to the docs,
On Wednesday, 2 March 2016 at 05:04:37 UTC, David G. Maziero
wrote:
void RenderText( FontBMP font, int x, int y, const char* text,
Just one more correction for future reference, RenderText should
be
extern(C) void RenderText...
in order for it to work correctly with va_start/etc.
Thanks, fixing this single issue solved the compiler crash too.
Thanks also for the tip using hasUDA! Works nicely!
On Wednesday, 2 March 2016 at 05:04:37 UTC, David G. Maziero
wrote:
char[256] buff;
va_list ap;
va_start( ap, text );
sprintf( buff.ptr, text, ap );
va_end( ap );
Sorry again, where it reads "sprintf" should be "vsprintf".
I figured out what I wanted. Thanks for your answer Mike, sorry
to bother you though.
Here's the result:
void RenderText( FontBMP font, int x, int y, const char* text,
... )
{
SDL_Rect rect1, rect2;
rect2.x = x;
rect2.y = y;
rect2.w = font.width;
I forgot to add that the "RenderText(font,0,0,"FPS:
"~to!string(fps));" was an older version where it wasn't const
char *, but string. And I was using a foreach, so no
null-termination. But that's beyond the point of not using GC.
Yes, I'm aware of the null-termination thing. I might have pasted
code that I already changed.
But I already messed with sformat, and it seems that it does use
the GC. I've put @nogc in RenderText, and the compiler says
sformat uses GC, so I don't know.
But the thing is, I don't want to
On Wednesday, 2 March 2016 at 04:12:13 UTC, Mike Parker wrote:
char buf[1024];
Ugh. And the proper declaration in D:
char[1024] buf;
On Sunday, 28 February 2016 at 11:06:26 UTC, Jacob Carlborg wrote:
On 2016-02-28 04:33, Joel wrote:
Things just silently not work.
Joels-MacBook-Pro:packages joelcnz$ ls -l -a ~/ | grep dub
drwxr-xr-x4 joelcnz staff 136 26 Sep 12:47 .dub
Joels-MacBook-Pro:packages joelcnz$
That
On Wednesday, 2 March 2016 at 01:39:13 UTC, David G. Maziero
wrote:
Consider the following function:
void RenderText( FontBMP font, int x, int y, const char* text )
{
for( int r=0; text[r]!='\0'; ++r )
{
You're asking for trouble here. There's no guarantee that any D
On Wednesday, 2 March 2016 at 02:36:50 UTC, Charles wrote:
Watched a video on Jonathan Blow's language that he's
developing, and he has a pretty neat idea of having tools being
part of the language. Looking at the first 15
minutes(https://www.youtube.com/watch?v=OHZwYYW9koI) or so of
the
On 02/03/16 3:50 PM, Hanh wrote:
Hi,
Is there a way to declare a class field 'auto'? I have a problem when I
try to 'promote' a variable to a field.
import std.csv;
import std.typecons;
class Test {
this() {
auto text = "Joe,Carpenter,30\nFred,Blacksmith,40\r\n";
On Wednesday, 02 March, 2016 10:23 AM, ric maicle wrote:
Shouldn't this print 'float'?
writeln(typeof(0x123f).stringof);
Oh man, I should better sleep!
Hi,
Is there a way to declare a class field 'auto'? I have a problem
when I try to 'promote' a variable to a field.
import std.csv;
import std.typecons;
class Test {
this() {
auto text = "Joe,Carpenter,30\nFred,Blacksmith,40\r\n";
auto reader =
Watched a video on Jonathan Blow's language that he's developing,
and he has a pretty neat idea of having tools being part of the
language. Looking at the first 15
minutes(https://www.youtube.com/watch?v=OHZwYYW9koI) or so of the
video, is this something that could be accomplished in D with
Shouldn't this print 'float'?
writeln(typeof(0x123f).stringof);
On 03/01/2016 05:11 PM, asdf wrote:
> import std.stdio : writeln;
>
> struct foo
> {
> long* bar;
>
> this (long l)
> {
> long d = l;
> bar =
Unfortunately, 'bar' is pointing at the temporary stack-based variable 'd'.
> }
> }
>
> int main()
> {
> foo
Hi. I think it's the first time I post here.
I've been flirting with D for some time, but now I decided to
start a little project.
Consider the following function:
void RenderText( FontBMP font, int x, int y, const char* text )
{
SDL_Rect rect1, rect2;
rect2.x = x;
On Tuesday, 1 March 2016 at 17:21:16 UTC, David DeWitt wrote:
On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote:
I am aiming to become a hardcore and better coder(quality
code) than you :) Please suggest.
I'd probably skim thru the Language Reference and Phobos.
Just to add to this -
On 03/01/2016 12:40 PM, Daniel Kozak wrote:
Yep, I have my copy (even print one) for some time on my desk :)
https://twitter.com/kozzi11/status/700340359927349249
Nooo! :( :p
Ali
import std.stdio : writeln;
struct foo
{
long* bar;
this (long l)
{
long d = l;
bar =
}
}
int main()
{
foo f = foo(12345);
writeln(*f.bar);
//writefoo(f);
writeln(*f.bar);
return 0;
}
void writefoo(foo f)
{
writeln(*f.bar);
}
If I
On 01.03.2016 22:30, Tamas wrote:
struct Tag {}
template isTagged(S) {
enum bool isTagged =
delegate() {
foreach(attr; __traits(getAttributes, S)) {
static if (is(attr == Tag)) {
return true;
}
}
On Tuesday, 1 March 2016 at 21:30:44 UTC, Tamas wrote:
foreach(attr; __traits(getAttributes, S)) {
static if (is(attr == Tag)) {
return true;
}
}
return false;
}();
}
void main() {
static @Tag struct
On Tuesday, 1 March 2016 at 21:30:44 UTC, Tamas wrote:
My d code doesn't compile using ldc2 1.0.0-alpha or anything
above DMD v2.068.0
Using these compilers I get a lot of "Warning: statement is not
reachable". Then the both compiler crashes.
ldc2 -w reach.d
dmd -w reach.d
reach.d:
My d code doesn't compile using ldc2 1.0.0-alpha or anything
above DMD v2.068.0
Using these compilers I get a lot of "Warning: statement is not
reachable". Then the both compiler crashes.
I minimized the code to get the same warning, although the
compilers do not crash this time, so this
On Tuesday, 1 March 2016 at 17:53:27 UTC, David DeWitt wrote:
On Tuesday, 1 March 2016 at 17:21:16 UTC, David DeWitt wrote:
On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote:
I am almost done with the "programming in D" book. Where will
you suggest a go from there. My current focus is
On Tuesday, 1 March 2016 at 20:26:36 UTC, Ali Çehreli wrote:
On 03/01/2016 12:17 PM, Wulfrick wrote:
On Tuesday, 1 March 2016 at 20:15:00 UTC, Wulfrick wrote:
It looks like the link in wiki.dlang.org/Videos to Andrei's
"Three
Cool Things about D" is dead.
Do you know of another link?
Maybe
On Tuesday, 1 March 2016 at 19:59:19 UTC, Ali Çehreli wrote:
On 03/01/2016 08:50 AM, karabuta wrote:
I am almost done with the "programming in D" book. Where will
you
suggest a go from there.
Like others said, I would spend time on Phobos to become
familiar with it; there are many gems in
On 03/01/2016 12:17 PM, Wulfrick wrote:
On Tuesday, 1 March 2016 at 20:15:00 UTC, Wulfrick wrote:
It looks like the link in wiki.dlang.org/Videos to Andrei's "Three
Cool Things about D" is dead.
Do you know of another link?
Maybe this?
https://www.youtube.com/watch?v=3NihZVcZqto
Yes, that
On Tuesday, 1 March 2016 at 20:15:00 UTC, Wulfrick wrote:
It looks like the link in wiki.dlang.org/Videos to Andrei's
"Three Cool Things about D" is dead.
Do you know of another link?
Maybe this?
https://www.youtube.com/watch?v=3NihZVcZqto
It looks like the link in wiki.dlang.org/Videos to Andrei's
"Three Cool Things about D" is dead.
Do you know of another link?
On 03/01/2016 08:50 AM, karabuta wrote:
I am almost done with the "programming in D" book. Where will you
suggest a go from there.
Like others said, I would spend time on Phobos to become familiar with
it; there are many gems in there.
I am still reading both Mike Parker's "Learning D" and
On Tuesday, 1 March 2016 at 17:21:16 UTC, David DeWitt wrote:
On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote:
I am almost done with the "programming in D" book. Where will
you suggest a go from there. My current focus is on network
programming, database systems, data manipulation and
On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote:
I am almost done with the "programming in D" book. Where will
you suggest a go from there. My current focus is on network
programming, database systems, data manipulation and software
architectures for database related apps(mostly Linux
On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote:
I am almost done with the "programming in D" book. Where will
you suggest a go from there. My current focus is on network
programming, database systems, data manipulation and software
architectures for database related apps(mostly Linux
On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote:
I am almost done with the "programming in D" book. Where will
you suggest a go from there. My current focus is on network
programming, database systems, data manipulation and software
architectures for database related apps(mostly Linux
I am almost done with the "programming in D" book. Where will you
suggest a go from there. My current focus is on network
programming, database systems, data manipulation and software
architectures for database related apps(mostly Linux platforms
with D).
I am aiming to become a hardcore and
On Tuesday, 1 March 2016 at 08:53:20 UTC, Adrian Matoga wrote:
struct Foo
{
string foo = "dog";
int bar = 42;
int baz = 31337;
}
void set(P, T)(ref P p, string name, auto ref T value)
{
foreach (mem; __traits(allMembers, P)) {
static if
On 3/1/16 12:44 AM, Mike Parker wrote:
On Tuesday, 1 March 2016 at 01:31:56 UTC, Jirka wrote:
Ok, that would throw some OOM exception instead so I wouldn't need to
bother with it, is there something else in the GC that would override
it during class instance allocation? I am finding it weird
On Monday, 29 February 2016 at 17:38:11 UTC, ZombineDev wrote:
On Monday, 29 February 2016 at 12:43:39 UTC, Chris wrote:
[...]
I'm almost sure that built-in AAs don't provide automatic
synchronization (in my tests I hit a deadlock), but you can
easily wrap the AA into a struct that does the
On Tuesday, 1 March 2016 at 13:41:38 UTC, Nemo wrote:
On Tuesday, 1 March 2016 at 13:35:08 UTC, Andrea Fontana wrote:
This very very simple function [1] won't compile.
It says that param t is not nothrow. Why? What's wrong with
this?
http://dpaste.dzfl.pl/bfc382e62711
writeln isn't nothrow
64 matches
Mail list logo