On 03/02/2012 06:30 PM, Piotr Szturmaj wrote:
> Hello,
>
> For this code:
>
> auto c = "test"c;
> auto w = "test"w;
> auto d = "test"d;
> pragma(msg, typeof(c.front));
> pragma(msg, typeof(w.front));
> pragma(msg, typeof(d.front));
>
> compiler prints:
>
> dchar
> dchar
> immutable(dchar)
>
> IMO
On Sat, Mar 03, 2012 at 03:33:46AM +0100, Adam D. Ruppe wrote:
> On Saturday, 3 March 2012 at 02:19:55 UTC, Andrej Mitrovic wrote:
> >Right, but what about template bloat?
>
> You don't have to use templates at all. The __FILE__
> and __LINE__ default params work in regular functions.
>
>
Ah yeah, I forgot about those.
int opIndex(int x, int line = __LINE__, string file = __FILE__)
Tada. I overcomplicated.
On Saturday, 3 March 2012 at 02:19:55 UTC, Andrej Mitrovic wrote:
Right, but what about template bloat?
You don't have to use templates at all. The __FILE__
and __LINE__ default params work in regular functions.
// not a template, just regular parameters
void awesome(string file =
Hello,
For this code:
auto c = "test"c;
auto w = "test"w;
auto d = "test"d;
pragma(msg, typeof(c.front));
pragma(msg, typeof(w.front));
pragma(msg, typeof(d.front));
compiler prints:
dchar
dchar
immutable(dchar)
IMO it should print this:
immutable(char)
immutable(wcha
On 3/3/12, Adam D. Ruppe wrote:
> Since some time last year, it works on all functions, just
> use regular default parameters:
Right, but what about template bloat? DMD doesn't seem to merge these
templates. It can try to inline them, but it's very easy to break the
inliner. E.g.:
int myFunc(str
On Saturday, 3 March 2012 at 01:46:05 UTC, Andrej Mitrovic wrote:
Well, there is a way but it might wreak havoc on your object
size since it will instantiate a lot of templates.
Since some time last year, it works on all functions, just
use regular default parameters:
// test9.d
import std.st
Ok this works: http://paste.pocoo.org/show/560103/
Err wait a minute, that debug/else thing doesn't quite work well.. I
thought it would.
On 3/3/12, Andrej Mitrovic wrote:
> throw new Exception(format("%s: %s", file, line));
That format is unnecessary but anywho. :)
Well, there is a way but it might wreak havoc on your object size
since it will instantiate a lot of templates. Therefore it would be a
good thing to only do it in debug mode:
import std.string;
class A
{
int opIndexDebug(int line = __LINE__, string file = __FILE__)(int x)
{
/* do
On Saturday, 3 March 2012 at 01:36:51 UTC, H. S. Teoh wrote:
int opIndex(int x) {
Make that
(int x, string file = __FILE__, int line = __LINE__)
and use file/line in there. The exception consturctors
do this, so you can
throw new Exception("msg", file, line);
and get it pass
Is it possible to get at the file and line number of where a function is
being called from? For example:
class A {
int opIndex(int x) {
/* do a bunch of checks */
if (checkFailed)
throw new Rang
On Saturday, 3 March 2012 at 00:03:02 UTC, Yao Gomez wrote:
On Friday, 2 March 2012 at 22:56:49 UTC, tjb wrote:
Ali,
Thanks. That helps me see how to use a structure. I just
need to
figure out the date and time conversion.
Thanks!
TJB
I don't remember who did it or where is located, but
On Friday, 2 March 2012 at 22:56:49 UTC, tjb wrote:
Ali,
Thanks. That helps me see how to use a structure. I just need
to
figure out the date and time conversion.
Thanks!
TJB
I don't remember who did it or where is located, but there's
actually a project/code that can be used for conver
Ali,
Thanks. That helps me see how to use a structure. I just need to
figure out the date and time conversion.
Thanks!
TJB
On 03/02/2012 02:01 PM, Yao Gomez wrote:
On Friday, 2 March 2012 at 21:50:12 UTC, tjb wrote:
Woops. I have a mistake in the code. Should be:
import std.stdio : writeln;
import std.stream;
void main() {
auto fin = new File("temp.csv");
char[] line;
int count;
while(!fin.eof()) {
line = fin.rea
Yao,
Thanks. That looks perfect. I'll play with it until I figure it out.
Any suggestions for the date and time variables?
Thanks again!
TJB
On Friday, 2 March 2012 at 21:50:12 UTC, tjb wrote:
Woops. I have a mistake in the code. Should be:
import std.stdio : writeln;
import std.stream;
void main() {
auto fin = new File("temp.csv");
char[] line;
int count;
while(!fin.eof()) {
line = fin.readLine();
writeln(line);
Woops. I have a mistake in the code. Should be:
import std.stdio : writeln;
import std.stream;
void main() {
auto fin = new File("temp.csv");
char[] line;
int count;
while(!fin.eof()) {
line = fin.readLine();
writeln(line);
}
}
Thanks!
TJB
Hello,
I am trying to read some data from a csv file into a struct. I'm just learning
to use
D. This little bit of code reads the data and prints to standard output just
fine:
import std.stdio : writeln;
import std.stream;
void main() {
auto fin = new File("temp.csv");
char[] line;
in
On 02-03-2012 21:54, Ali Çehreli wrote:
On 03/02/2012 12:48 PM, Alex Rønne Petersen wrote:
Hi,
Is there any way I can tell the GC that a block of memory does not
contain any possible pointers (in)to other GC-managed memory?
Everything about the GC should be in the core.memory module. I think
On 03/02/2012 01:08 PM, Andrej Mitrovic wrote:
> Is there a reason why there's no .empty property for hashes? std.array
> defines it for arrays, and range types must have it defined.
Yes, empty is a part of the InputRange interface. Slices are InputRange
ranges but associative arrays are not. Un
Is there a reason why there's no .empty property for hashes? std.array
defines it for arrays, and range types must have it defined. But
hashes are left out even though they define .length. This could be put
in std.array:
@property bool empty(T)(in T a)
if (isAssociativeArray!T)
{
return !a
On 03/02/2012 12:48 PM, Alex Rønne Petersen wrote:
Hi,
Is there any way I can tell the GC that a block of memory does not
contain any possible pointers (in)to other GC-managed memory?
Everything about the GC should be in the core.memory module. I think
what you need is removeRange(). Or you
Hi,
Is there any way I can tell the GC that a block of memory does not
contain any possible pointers (in)to other GC-managed memory?
--
- Alex
On Fri, 02 Mar 2012 20:30:07 +0100, David Nadlinger wrote:
> On Friday, 2 March 2012 at 18:10:56 UTC, Jonathan M Davis wrote:
>> Both should work, and the man page is going to be for git-rebase.
>> Pretty much
>> all of the git commands can be used with or without a -.
>
> On my system, the dashe
Twitter messages are pretty limited, so I think it could make sense to
implement a QR code based twitter like information-service. D could be
the tool of choice, But does this idea makes sense at all ? I Think so,
but would like to hear your opinion.
TIA
Bjoern
On Friday, 2 March 2012 at 18:10:56 UTC, Jonathan M Davis wrote:
Both should work, and the man page is going to be for
git-rebase. Pretty much
all of the git commands can be used with or without a -.
On my system, the dashed commands are not directly accessible,
and the man page exclusively u
On Friday, March 02, 2012 14:47:00 Graham Fawcett wrote:
> On Thu, 01 Mar 2012 17:16:59 -0500, Jonathan M Davis wrote:
> > If you make changes in a branch and want them on top of what's in
> > master, then do
> >
> > git-rebase master
>
> While "git-rebase" may be available on your system, I thin
On Thu, 01 Mar 2012 17:16:59 -0500, Jonathan M Davis wrote:
>
> If you make changes in a branch and want them on top of what's in
> master, then do
>
> git-rebase master
While "git-rebase" may be available on your system, I think the typical
spelling would be
git rebase master
Graham
> in
SDL_LoadBMP is declared as:
SDL_Surface *SDL_LoadBMP(const char *file);
http://www.libsdl.org/cgi/docwiki.cgi/SDL_LoadBMP
So you don't need a mutable char*. I'd recommend using Derelict since
it already has all these prototypes declared properly.
On 2012-03-02 11:23:20 +, Ali Çehreli said:
On 03/02/2012 02:18 AM, Magnus Lie Hetland wrote:
I'm writing a template for generating data of some possibly immutable
type -- e.g., a string. What I'm wondering is, is there some way of
accessing the mutable version of an immutable type?
Yes,
On 03/02/2012 12:12 AM, bearophile wrote:
Ali:
Note that Timon's inner foreach is a compile-time foreach, which is the
equivalent of the following three lines:
I'd like it to be written:
static foreach (...) {...
In the meantime an annotation helps clarify the code for the person that will
On 03/02/2012 02:18 AM, Magnus Lie Hetland wrote:
I'm writing a template for generating data of some possibly immutable
type -- e.g., a string. What I'm wondering is, is there some way of
accessing the mutable version of an immutable type?
Yes, std.traits.Unqual:
http://dlang.org/phobos/std_
I'm writing a template for generating data of some possibly immutable
type -- e.g., a string. What I'm wondering is, is there some way of
accessing the mutable version of an immutable type?
I mean, I could do something like (for strings and related immutable arrays)...
void func(T)(ref immutab
On 2012-03-02 07:40, James Miller wrote:
On 2 March 2012 18:52, Alex Rønne Petersen wrote:
Hi,
Are there any actively-maintained Cocoa bindings for D?
--
- Alex
Not as far as I know.
You should make some!
--
James Miller
Bindings and bridge:
http://www.dsource.org/projects/dstep
The b
On 2012-03-01 16:34:23 +, Ali Çehreli said:
Since there are also sub-normal values between 0 and T.min_normal, it
may make sense to use the range [T.min_normal, 1) and scale the result
from there. But I haven't tested whether the distinct values in that
range are equally distributed.
I g
On 2012-03-01 16:34:23 +, Ali Çehreli said:
I recommend reading this page:
http://dlang.org/d-floating-point.html
Thanks.
Especially the ASCII graph there is very interesting. The number of
distinct values between T.min_normal and 1 are equal to the distinct
values between 1 and T.
39 matches
Mail list logo