Removing an element from a DList

2023-10-17 Thread Joakim G. via Digitalmars-d-learn
For some reason I cannot remove an element from a DList. I tried several range approaches but to no avail. I'm a noob. In the end I did this: ``` private void removeFromWaitingQueue(uint jid) { auto arr = waitingQueue[].array; arr = arr.remove!(job => job.jid == jid);

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
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.

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
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".

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
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;

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
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.

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
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

Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
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;

Re: LINK : fatal error LNK1104: cannot open file '_CMDLINE' --- errorlevel 1104

2016-01-11 Thread Tobi G. via Digitalmars-d-learn
On Monday, 11 January 2016 at 20:19:50 UTC, Jason Jeffory wrote: Sheesh, why is it so hard to do simple stuff? 1) Have you tryed passing --arch=x86_64 to dub? 2) > "versions-x86_64": ["XYZ"] This is like a architecture dependent condition for version definition. So if your project will

Re: Using std.conv.to with std.typecons.Typedef

2016-01-11 Thread Tobi G. via Digitalmars-d-learn
On Monday, 11 January 2016 at 08:03:19 UTC, Saurabh Das wrote: How can I get std.conv to understand std.typecons.Typedef? You can do something like this: QuestionId q = to!(TypedefType!QuestionId)("43"); In general, is there a better solution to orthogonal types than Typedef? Typedef is

Re: Using std.conv.to with std.typecons.Typedef

2016-01-11 Thread Tobi G. via Digitalmars-d-learn
On Monday, 11 January 2016 at 12:15:55 UTC, Saurabh Das wrote: Any ideas? Yes. Because Typedef is introducing new Types, which csvReader doesn't know what they are, you'll need a little workaround and cast the values yourself. import std.csv, std.stdio, std.algorithm, std.range; enum

Re: Function accepts const ubyte[], const char[], immutable ubyte[], immutable char[]

2016-01-10 Thread Tobi G. via Digitalmars-d-learn
On Sunday, 10 January 2016 at 10:10:46 UTC, zabruk70 wrote: Hello. 1st Novice question: i want function, operates sometimes with char[], sometimes with ubyte[]. internally it works with ubyte. i can use overloading: void myFunc(ubyte[] arg) {...}; void myFunc(char[] arg) { ubyte[] arg2 =

Re: Bug in csv or byLine ?

2016-01-10 Thread Tobi G. via Digitalmars-d-learn
The bug has been fixed...

Re: Bug in csv or byLine ?

2016-01-10 Thread Tobi G. via Digitalmars-d-learn
On Sunday, 10 January 2016 at 09:41:16 UTC, Keywan Ghadami wrote: On Friday, 8 January 2016 at 13:53:06 UTC, Guillaume Chatelet wrote: I still do not understand half of the syntax(still learning) but my guess is that it is a bug in the csv reader: In

Re: Bug in csv or byLine ?

2016-01-10 Thread Tobi G. via Digitalmars-d-learn
On Sunday, 10 January 2016 at 19:07:52 UTC, Jesse Phillips wrote: On Sunday, 10 January 2016 at 18:09:23 UTC, Tobi G. wrote: The bug has been fixed... Do you have a link for the fix? Is there a BugZilla entry? Yes sure.. https://issues.dlang.org/show_bug.cgi?id=15545 and the fix at github

Re: Is this rdmd bug or my fault ?

2016-01-08 Thread Tobi G. via Digitalmars-d-learn
On Friday, 8 January 2016 at 15:45:52 UTC, zabruk70 wrote: Should i create bugreport, or this is my mistake? I get also a compilation error (with rdmd and -g). Fortunately building manually with dmd works. So there has to be a bug in rdmd.. togrue

Re: Bug in csv or byLine ?

2016-01-08 Thread Tobi G. via Digitalmars-d-learn
On Friday, 8 January 2016 at 09:59:26 UTC, Guillaume Chatelet wrote: Any idea ? No, sorry. Under Windows DMD v2.069.2 it works perfectly in both cases. Which compiler do you use? You could run DMD with the -g option. This will print often more useful output, if it fails. togrue

Re: Bug in csv or byLine ?

2016-01-08 Thread Tobi G. via Digitalmars-d-learn
On Friday, 8 January 2016 at 12:13:59 UTC, Guillaume Chatelet wrote: On Friday, 8 January 2016 at 12:07:05 UTC, Tobi G. wrote: No, sorry. Under Windows DMD v2.069.2 it works perfectly in both cases. Which compiler do you use? - DMD64 D Compiler v2.069.2 on Linux. - LDC 0.16.1 (DMD v2.067.1

Re: RedBlackTree and myClass

2016-01-03 Thread Tobi G. via Digitalmars-d-learn
On Sunday, 3 January 2016 at 14:49:59 UTC, tsbockman wrote: On Sunday, 3 January 2016 at 10:55:05 UTC, AntonSotov wrote: import std.container.rbtree; class myClass { string str; } int main() { auto tree = new RedBlackTree!myClass; return 0; } Error: mutable method

Re: RedBlackTree and myClass

2016-01-03 Thread Tobi G. via Digitalmars-d-learn
On Sunday, 3 January 2016 at 16:44:35 UTC, tsbockman wrote: If it's a private internal data structure which is only used a few places, then sure - just use the minimum code required to get the job done. But, if it's a part of the public API for a module and the class logically has a natural

Re: immutable promise broken in unions?

2016-01-02 Thread Tobi G. via Digitalmars-d-learn
On Saturday, 2 January 2016 at 10:04:47 UTC, Shriramana Sharma wrote: I thought the promise of `immutable` was: never changes. The compiler doesn't protect you by carrying a bomb. :) But there is another usecase where it makes sense to allow writing to other union members despite the

Re: Why does this not work?

2016-01-01 Thread Tobi G. via Digitalmars-d-learn
On Friday, 1 January 2016 at 14:00:41 UTC, TheDGuy wrote: writeln("Which number should i guess?"); string input = readln(); int i = to!int(input); The solution is that readln() returns a string that also contains the newline this can be solved by easily stripping the

Re: Why does this not work?

2016-01-01 Thread Tobi G. via Digitalmars-d-learn
On Friday, 1 January 2016 at 14:20:26 UTC, Tobi G. wrote: The solution is that readln() returns a string that also contains the newline this can be solved by easily stripping the newline off import std.string; int i = to!int(input.strip); Sorry my bad english.. i wrote solution but meant

DList access the previous element

2016-01-01 Thread Tobi G. via Digitalmars-d-learn
I'd like to implement a Skyline Rectangle packing algorithm. A DList should store the actual Skyline. (So the order is important, it will mostly have to access the right or left node element) And a Binary Heap which should hold a pointer to every DList element. (Mostly for fast accessing the

Re: How to build dfmt?

2016-01-01 Thread Tobi G. via Digitalmars-d-learn
On Friday, 1 January 2016 at 14:20:05 UTC, Suliman wrote: https://github.com/Hackerpilot/dfmt After run build.bat nothing do not happens. How can I build it? The easiest way to do it is to download and install dub - the package manager from https://code.dlang.org/ and then run dub fetch

gaming pointers

2010-12-28 Thread g g
maade something obvious or silly. Thanks g.

is this the expected output

2010-12-22 Thread g g
reuses the same address? I got hit by this trying to do a tree structure builder, for hours searching aand finally found this (feature | bug). If so, how I could get a new struct to void changing (in a unnoticeable way) the same struct i just set. thanks. g g

Re: is this the expected output

2010-12-22 Thread g g
Thanks for the answers what I did is this ( i feel that it is quite clumsy): Node* x = cast(Node*) (GC.malloc(Node.sizeof)); *x = xa; x.up = curnode; ...

Re: ditto in DDoc

2010-10-08 Thread Yao G.
of a document. -- Yao G.

Re: dcollection docs

2010-09-27 Thread Yao G.
). They don't have licence because I didn't find an equivalent to the Boost Licence but for documentation, but they can be used freely for whatever need you have. I still have to make some improvements, for example create a tree of symbols, like the one in Kandil or CandyDoc. -- Yao G.

Re: dcollection docs

2010-09-27 Thread Yao G.
of Dil. -- Yao G.

Re: date and time

2010-09-25 Thread Yao G.
to file. Thanks in advance. :-) std.datetime is your friend. http://www.digitalmars.com/d/2.0/phobos/std_date.html -- Yao G.

Translation of C function pointer.

2010-09-15 Thread Yao G.
to convert it to a D function pointer. Certainly, the inner pointer is easy: void (* function(sqlite3_vfs*,void*, const(char) *zSymbol) xDlSym)(); But what about the outer one? I am missing something? Thanks in advance. -- Yao G.

Re: Translation of C function pointer.

2010-09-15 Thread Yao G.
, typeof(xDlSym).stringof); outputs: void function() function(sqlite3_vfs*, void*, const const(char*) zSymbol) so I think it's a function pointer that takes those parameters and returns a function pointer that takes no parameters and returns nothing. -Steve Thanks Steve! -- Yao G.

void[] vs byte[]

2010-08-28 Thread Yao G.
is byte[] (chunk in std.stdio). Is there a place where this stuff is documented? Or choosing one or another is just a matter of preference and the differences are trivial? Thanks in advance. -- Yao G.

Re: Compound assignment operators

2010-08-26 Thread Yao G.
) { } - Jonathan M Davis Ha ha ha! What a shame, I was reading that page looking for a solution, but it seems that I just skipped that part. Thanks and sorry for the stupid question. -- Yao G.

Compound assignment operators

2010-08-25 Thread Yao G.
this; } private int _bar; } void main() { au -- Yao G.

Re: Compound assignment operators

2010-08-25 Thread Yao G.
' is not of arithmetic type, it is a Foo Error: 'f2' is not of arithmetic type, it is a Foo Is there a way to make this work? Even changing the operator string in opBinary to - doesn't do nothing. Or those kind of operators can't be overloaded? -- Yao G.

Re: TDPL: Operator Overloading

2010-08-24 Thread Yao G.
); But if I ever tried a call like CheckedInt(10) in a unittest block, it wouldn't work. So how does this magic work? http://www.digitalmars.com/d/2.0/mixin.html -- Yao G.

Re: TDPL: Operator Overloading

2010-08-24 Thread Yao G.
with more experience on templates can give you a better (or correct, I'm just guessing this :) ) answer. -- Yao G.

Re: How do you call GetVersionEx (Windows)?

2010-08-23 Thread Yao G.
Relevant links: http://dsource.org/projects/bindings/wiki/WindowsApi http://dsource.org/projects/bindings/browser/trunk/win32 -- Yao G.

Re: How do you call GetVersionEx (Windows)?

2010-08-23 Thread Yao G.
For my projects, I rolled my own headers. They are based (like the ones on dsource) on the MinGW32 project. But mine target Windows 2000 as minimal O.S. and use exclusively UTF-32 (the ASCI versions are not defined). Also, Replace UTF-32 with UTF-16 :D -- Using Opera's revolutionary

Re: floor, ceil equivalent

2010-08-22 Thread Yao G.
/std_math.html#ceil -- Yao G.

Re: How do you call GetVersionEx (Windows)?

2010-08-22 Thread Yao G.
modified lib files with more functions defined. The ones that come bundled with DMD are severely outdated. If you have some linking problems, try to use the aliases that I suggested on the code comments. -- Yao G.

Re: How do you call GetVersionEx (Windows)?

2010-08-22 Thread Yao G.
; And make the change to the TCHAR alias too. Remember that a lot of Windows functions, specially the ones that deal with strings and characters, have two versions: functionNameA for ASCI/UTF-8 and functionNameW for UTF-16. -- Yao G.

Re: How do you call GetVersionEx (Windows)?

2010-08-22 Thread Yao G.
. Specially the newer ones. I grabbed the lib files I use from a link that somebody posted here in the NG a few years ago. Sadly I can't find that link anymore. -- Yao G.

Re: How to avoid the console from apearing.

2010-08-17 Thread Yao G.
: --- import core.runtime; import std.c.windows.windows, std.process; extern(Windows) int WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) { return system( rbin\someprogram.exe ); } --- -- Yao G.

shared libraries in linux

2010-08-15 Thread g g
I have successfully made funtions and structs in shared libraries in linux with dmd, but i have no idea how to do that with classes, and how call the static this() funtion of the linked module, because variables ( even immutable ) are not correctly set without calling it. Thanks. gzkp0s

typedef alternative

2010-08-14 Thread Yao G.
(1), Month(1) ); --- So, what options do I have? I know that typedef is scheduled to deprecation, so I would like to know if there's something else. -- Yao G.

Re: typedef alternative

2010-08-14 Thread Yao G.
need, for example, that if you pass a Year instance to the Month parameter, generate a compiler error. -- Yao G.

Re: typedef alternative

2010-08-14 Thread Yao G.
the types that I'm defining are value types. But thanks for the answer -- Yao G.

Re: typedef alternative

2010-08-14 Thread Yao G.
this; } } else static if ( type == Type.Sub ) { @disable void opAssign( T value ); } } I think I'll do something similar as this. I don't need either explicit or implicit cast between types. -- Yao G.

Re: typedef alternative

2010-08-14 Thread Yao G.
DatePartImpl!(DatePart.Day) Day; void foo( Year y, Month m, Day d ) {} // Works correctly foo( Year(2010), Month(8), Day(14) ); // But this isn't allowed foo( Day(14), Year(2010), Month(8) ); --- -- Yao G.

ddoc file on command line

2010-08-10 Thread Yao G.
. The docbook.ddoc is on the same directory where I have the *.d files (code). Thanks in advance. -- Yao G.

Re: ddoc file on command line

2010-08-10 Thread Yao G.
I forgot to mention that I'm using the latest (beta) version of DMD 2 on Windows XP. On Tue, 10 Aug 2010 20:52:18 -0500, Yao G. nospam...@gmail.com wrote: According to the DDOC spec (http://digitalmars.com/d/2.0/ddoc.html) if you want to redefine some macros, one way is to pass one file

Re: D and a bazillion of small objects

2010-06-03 Thread Yao G.
Thanks bearophile. I'll give it a try later. -- Yao.G On Thu, 03 Jun 2010 12:27:20 -0500, bearophile bearophileh...@lycos.com wrote: Yao G.: I think the idea of a memory pool or freelist is good. Can you point me where can I see your libs? Instead of just giving you a link to the dlibs1

D and a bazillion of small objects

2010-06-02 Thread Yao G.
the copies and to make effective all the item modification across all copies. But then I would be where I started: doing tons of heap allocations. So, how should I deal with this issue? Thanks. Yao G.

String literal arguments

2010-04-07 Thread Yao G.
Hello. I'm trying to learn more of D templates, but I'm stuck with an issue I cannot resolve. Well, actually, I don't know if this is even allowed, and that's why I'm posting here. Suppose I have a function declared like this: --- import std.traits; void foo(T...)(T args) if(

Re: String literal arguments

2010-04-07 Thread Yao G.
On Wed, 07 Apr 2010 03:05:34 -0400, Simen kjaeraas simen.kja...@gmail.com wrote: Yao G. nospamyaolt...@gmail.com wrote: Hello. Greetings. foo( Hello World, first, second ); --- You can notice that the first argument is a string literal. What I want to know is: If a function argument

Re: incomprehensible return error bug?

2010-01-24 Thread g
strtr Wrote: strtr Wrote: This error also points to the enum which is probably incorrectly used somewhere s_def(32) Error: cannot implicitly convert expression (5) of type int to S Still searching for the original bug btw :( Found it, also a return type mismatch problem;

Re: incomprehensible return error bug?

2010-01-24 Thread g
g Wrote: strtr Wrote: strtr Wrote: This error also points to the enum which is probably incorrectly used somewhere s_def(32) Error: cannot implicitly convert expression (5) of type int to S Still searching for the original bug btw :( Found it, also a return type

Re: help with RegExp not matching [D1]

2009-11-22 Thread g
, or simpley beacuse nones know what to say. In your case, i would say that be more explicit and don't be like resolve my homework now. just general recomendations, and be patient. best regards. g

Re: Help needed to actualizing allegro bindings (or this bindings

2009-11-15 Thread g
div0 Wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 g wrote: g Wrote: I have been trying to actualize the http://www.dsource.org/projects/dallegro binings to the lastest typo: it is bindings, not binings Downgrade your compiler version. Every version after 2.028 has

Help needed to actualizing allegro bindings (or this bindings are complex and I am dumb)

2009-11-14 Thread g
= allegro.internal.dintern.cpu_vendor.ptr; //_system_driver_list = allegro.misc._system_driver_list.ptr; } A strange way of wraping. So... Are there other bindings to allegro? Does anyone has actualized this bindings? Is Someone interested in helping? Should i abdicate? g

Re: Help needed to actualizing allegro bindings (or this bindings are complex and I am dumb)

2009-11-14 Thread g
g Wrote: I have been trying to actualize the http://www.dsource.org/projects/dallegro binings to the lastest typo: it is bindings, not binings

Fixed point arithmetic

2009-11-12 Thread g
is there any library for D that implements fixed point arithmetic. g

Re: CTFE and structs question

2009-11-08 Thread g
Don Wrote: You can do stuff like: struct Foo { int x; } enum Foo b = Foo(56); strange. you can do that only if there is no constructor. Also trying with templates, i got a segfault, i dont know if it is already reported. Why this segfaults?. At least it should print a error

CTFE and structs question

2009-11-07 Thread g
At what point structs are supported in CTFE. Cause this fails in dmd 2.036: import std.metastrings; pragma(msg,toStringNow!(A.init.a)); struct A{ uint a; } with this message (note that the end seems truncated): g...@g-desktop:~/Documentos/NCHESS$ dmd oh oh.d(3): Error: no property