Re: About File.rawWrite

2011-11-29 Thread torhu
On 29.11.2011 16:00, Denis Shelomovskij wrote: Your OS is Windows, right? On Windows, rawWrite and rawRead always flushes stream, sets binary mode, reads/writes, flushes stream again, sets previous mode. This is definitely unnecessary slow - at least it should change mode only if needed (the fil

Re: WinAPI LowLevel Keyboard Hooks

2012-07-21 Thread torhu
On 19.07.2012 13:45, DLimited wrote: Hello everyone, I had this great idea of writing a Program that intercepts all keyboard presses and modifies them in certain cases. I want to use it as some kind of global makro program to run in the background and for example allow me to easily post unicode

Re: FYI my experience with D' version

2012-07-30 Thread torhu
On 28.07.2012 22:55, Adam D. Ruppe wrote: After some experience, I've come to the conclusion that using D's version() with custom things is usually a mistake. Not always - I think it is still good for platform like tweaks, version(X86) or version(Windows), or even version(Custom_Library), (note,

Re: D1: Passing 0x00000000 value to a Windows COM function

2012-08-20 Thread torhu
On 20.08.2012 00:43, jicman wrote: Greetings. I am trying to pass a (I think) dchar value to a Windows COM function and it does not work. Imagine this situation... dchar test() { dchar val = 0x; return val } void main() { ...lots of code excluded SomeWindowsComCall(test);

Re: D1: Passing 0x00000000 value to a Windows COM function

2012-08-21 Thread torhu
On 20.08.2012 18:22, jicman wrote: ... dchar GetSourceLanguageEnumaration(char[] lang) { // *** STaggerF.SourceLanguage Enumeration *** dchar sl = 0x; lang = std.string.tolower(lang); //msgBox(lang); switch(lang) { case "sq", "sq-al": // stfTargetLanguageAlbania

Re: D1: Passing 0x00000000 value to a Windows COM function

2012-08-21 Thread torhu
On 20.08.2012 00:43, jicman wrote: Greetings. I am trying to pass a (I think) dchar value to a Windows COM function and it does not work. Imagine this situation... dchar test() { dchar val = 0x; return val } void main() { ...lots of code excluded SomeWindowsComCall(test);

Re: Export values (enum, int, char[]...) for DLL

2010-05-05 Thread torhu
On 04.05.2010 21:46, Nrgyzer wrote: Hello everybody, I'm trying to create a (very) simple DLL by using D. Now I want export values - is there any way do this... Off the top of my head, I think it goes like this: To export from a DLL: export int i = 7; To export from a DLL, with C name mangl

Re: Export values (enum, int, char[]...) for DLL

2010-05-06 Thread torhu
On 06.05.2010 16:06, Nrgyzer wrote: Thanks, but doesn't work :( My files contain: mydll.d: module mydll; export extern int i; mydll2.d: module mydll; export int i = 7; test.d: import mydll; import std.stdio; void main() { writefln(i); } I can compile the dll, but when I compile t

Re: Yet more OPTLINK woes

2010-05-12 Thread torhu
On 12.05.2010 13:22, Daniel Keep wrote: That's right, it's time for everyone's favourite [1] game: guess why OPTLINK's not working! [2] *sigh* I'm writing a math eval library. There are two test applications. LexerTest only touches part of the code. AstTest touches everything. Now, the fol

Re: Export values (enum, int, char[]...) for DLL

2010-05-13 Thread torhu
On 13.05.2010 18:23, Nrgyzer wrote: Nrgyzer Wrote: dmd now exports all values successfully. But when I try to export a class, I get the following errors: "Error 42: Symbol Undefined _D5mydll1t7__ClassZ Error 42: Symbol Undefined _D5mydll1t5_ctorMFZC11mydll1t" Source of mydll.d is: export clas

Re: Yet more OPTLINK woes

2010-05-13 Thread torhu
On 13.05.2010 10:39, Daniel Keep wrote: Attached both regular and decaffeinated^Hgutted versions. Most likely DMD turns VisitorCtfe.d into an invalid object file. But since you don't need to link with objects that contain only ctfe functions... Here's what I get: -- d:\prog\test\D\mathe

Re: Yet more OPTLINK woes

2010-05-13 Thread torhu
Seems I've got an older version of optlink, 8.00.1. With 8.00.2 I get the same behavior you did, but it still works if you don't link with VisitorCtfe.obj. When running 8.00.2 in the msvc debugger, it just looks like optlink successfully exits. No crash or anything. But no useful output eit

Re: lifetime of dynamically allocated memory

2010-05-31 Thread torhu
On 31.05.2010 22:27, dave wrote: I'm trying to figure out if a dynamically allocated memory in D is getting collected with this simple test (using tango): class Foo { ~this() { // destructor } } struct Item { Foo a; } Item[] items; items.length = 1; items[0] = Item(); i

Re: build problem with xfbuild

2010-06-10 Thread torhu
On 11.06.2010 00:46, Richard Webb wrote: If i try to use DMD 2.047 and xfbuild to compile a file which just contains module arraytest; import std.array; I get the error: F:\development\DTesting\dmd2\windows\bin\..\..\src\phobos\std\format.d(1882): Error: template std.array.Appender!(string).Ap

Re: Yet more OPTLINK woes

2010-06-14 Thread torhu
On 13.05.2010 21:07, torhu wrote: On 13.05.2010 10:39, Daniel Keep wrote: Attached both regular and decaffeinated^Hgutted versions. Most likely DMD turns VisitorCtfe.d into an invalid object file. But since you don't need to link with objects that contain only ctfe functions...

Re: Yet more OPTLINK woes

2010-06-15 Thread torhu
On 15.06.2010 01:34, torhu wrote: On 13.05.2010 21:07, torhu wrote: On 13.05.2010 10:39, Daniel Keep wrote: Attached both regular and decaffeinated^Hgutted versions. Most likely DMD turns VisitorCtfe.d into an invalid object file. But since you don't need to link with objects that co

Re: Replacement for din.readf

2010-06-16 Thread torhu
On 16.06.2010 23:23, Ali Çehreli wrote: I've been using din.readf to read from the standard input. Now that streams are being retired (some or all?), what is the best replacement? Thank you, Ali Try readln, lines, or rawRead from std.stdio.

Re: setMaxMailboxSize

2010-06-17 Thread torhu
On 17.06.2010 23:31, Byron Heads wrote: is setMaxMailboxSize not implemented yet or is it bugged? It's just an empty function currently. If you want to see for yourself, it's in dmd2/src/phobos/std/concurrency.d.

Re: How do I make an extern function?

2010-06-28 Thread torhu
On 29.06.2010 02:51, Simen kjaeraas wrote: module a; extern void foo( ); void bar( ) { foo( ); } module b; import std.stdio; void foo( ) { writeln( "Hi!" ); } The above does not work (Error 42: Symbol Undefined _D1a3f

Re: Recommended way to do RAII cleanly

2010-07-12 Thread torhu
On 12.07.2010 08:25, Jonathan M Davis wrote: Okay. There are cases where you want a constructor to do something when the class/struct is created, and you want the destructor to do something when the class/struct goes out of scope. A classic example would be an autolock for a mutex. Another would

Re: Recommended way to do RAII cleanly

2010-07-12 Thread torhu
On 13.07.2010 00:09, bearophile wrote: Jonathan M Davis: There are lots of cases where using scope(exit) makes sense, and it's a great construct. But there are also plenty of cases where using plain old RAII with a single declaration is better. It works fine in D as long as the struct in que

Re: Best practice and module declarations

2010-07-14 Thread torhu
On 15.07.2010 00:22, Jonathan M Davis wrote: I was wondering what the general consesus was (if there is one) on whether it's valuable to always put module declarations in each module. Obviously, if you need the module to have a name other than the file name, then you need to have the module decl

Re: Best practice and module declarations

2010-07-15 Thread torhu
On 15.07.2010 21:59, Rory McGuire wrote: From what I remember in TDPL: Can be used to rename a module if you have it in a different directory structure than how you use it. E.g. implementation and "headers" in separate folders. If you use *.di files (headers), you would normally just keep the

Re: Best practice and module declarations

2010-07-15 Thread torhu
On 15.07.2010 23:28, Rory McGuire wrote: On Thu, 15 Jul 2010 23:08:07 +0200, torhu wrote: On 15.07.2010 21:59, Rory McGuire wrote: From what I remember in TDPL: Can be used to rename a module if you have it in a different directory structure than how you use it. E.g. implementation

Re: CT usage only in executable

2010-07-17 Thread torhu
On 15.07.2010 02:29, strtr wrote: Not that the memory is really significant compared to the rest of my program, but I have a few fairly large arrays I use only in compile time and I was wondering why dmd still includes those in the executable (simple text search dug them up). As a workaround yo

Re: Equivalent of scanf

2010-07-17 Thread torhu
On 18.07.2010 00:41, Michael Koehmstedt wrote: I'm having trouble figuring out how to do formatted console input, something like C scanf() or C++ templated stream input. Unfortunately, console input isn't covered in much detail in TDPL book. There doesn't appear to be much discussion about the st

Re: Equivalent of scanf

2010-07-17 Thread torhu
On 18.07.2010 01:21, Michael Koehmstedt wrote: So there is no scanf equivalent, but there is also nothing similar to C++ cin with the<< operator? Equivalents of those are available in std.stream and std.cstream, but those modules will probably go away in a while.

Re: Is there a way to create compile-time delegates?

2010-07-19 Thread torhu
On 19.07.2010 21:06, Simen kjaeraas wrote: Yeah, what the subject says. I want to have a default delegate for a struct, and without a default constructor, this has to be a compile-time constant. Now, logically, there should be nothing wrong with storing the function pointer and a null context po

Re: monitor condition variables?

2010-07-20 Thread torhu
On 20.07.2010 19:21, Trass3r wrote: So synchronized implements mutual exclusion. http://www.digitalmars.com/d/2.0/class.html#synchronized-functions What about condition variables: http://en.wikipedia.org/wiki/Monitor_(synchronization)#Waiting_and_signaling Is there any standard way to do that?

Re: Extending the lifetime of scope objects

2010-07-20 Thread torhu
On 20.07.2010 21:54, Ali Çehreli wrote: What are all the cases that extend the lifetime of scoped objects? Binding a delegate to a scope object extends the lifetime of that object, which would normally end upon exiting that scope. The lifetime of i is extended here: int delegate(int) make_deleg

Re: const(type) vs. const type

2010-07-20 Thread torhu
On 21.07.2010 00:57, Mike Linford wrote: I'm playing with QtD, and I tried to override a QWidget's sizeHint() function, which is declared as const QSize sizeHint(). I tried to override it by declaring my function as override const(QSize) sizeHint () . I got a compiler error that it was "not covar

Re: Can't get D calling C to build.

2010-08-27 Thread torhu
On 23.08.2010 23:24, Bob Cowdery wrote: Addendum: The plot thickens. If I build a dll with my VC++ Express 2010 then I can convert the import library and it actually works from D. However if I build with MinGW GCC it doesn't even recognise the library even though it is COFF format. My preferred r

Re: Compiling Windows GUI-application

2010-08-27 Thread torhu
On 28.08.2010 00:58, Andrej Mitrovic wrote: Try compiling with -L/SUBSYSTEM:WINDOWS: -L/subsystem:windows:4 is better, maybe that's what you meant. Optlink defaults to an older version, which means some widgets don't work properly.

Re: built-in string hash ?

2010-08-28 Thread torhu
On 28.08.2010 16:37, Kevin Bailey wrote: So I have a class containing two strings: class Foo { string s1, s2; ... and I'd like to add a toHash() member, but I can't find the built-in string hash function. These don't work: s1.toHash() s1.toHash s1.hash s1.hash() hash(s1) yet

Re: writef: How to output hex byte?

2010-08-28 Thread torhu
On 29.08.2010 07:06, Nick Sabalausky wrote: ubyte myByte = 0x09; writef("%%%.2X", myByte); writef("%%%02X", myByte); On codepad.org (DMD 1.026 last time I checked), this prints this: %09%09 So it's probably a bug in the new formatting code. I assume it's supposed to follow the C behavior in

Re: Cannot find symbol using wine

2010-10-25 Thread torhu
On 25.10.2010 08:06, Jonathan M Davis wrote: [...] It looks liking adding advapi32.lib to the compilation command does the trick, but I don't know why I've never needed to do that before with other Windows functions. Just guessing, but it might be that dmd doesn't add advapi32.dll to the linke

Re: Bemused by this build error

2010-11-18 Thread torhu
On 14.11.2010 20:26, Bob Cowdery wrote: Hi I copied a module because I am changing its form. The original is still in the build but is a different package and class name. The closest thing I can think it might be talking about is this line: x_points[] = (x_average[0][]+x_average[1][]+x_average[

Re: Asian characters are not printed propely in console

2011-01-05 Thread torhu
On 04.01.2011 10:47, Jun wrote: I'm sorry for posting in the wrong place. I attached screenshot of my code and the result. As you can see, Korean letters get changed after compilation. This problem doesn't happen with user input(from readln() method). Should I use different type and prefix or

Re: std.date / std.datetime

2011-01-18 Thread torhu
On 18.01.2011 12:34, Richard Chamberlain wrote: Hello, I'm in the process of learning D, and to do so I'm converting some older code. I need to print out the current local date and time, which is causing some difficulties because std.date doesn't seem adequate in this respect. I understand ther

Re: DMD's kernel32.lib missing symbols?

2011-07-30 Thread torhu
On 30.07.2011 11:43, simendsjo wrote: On 29.07.2011 22:06, Simon wrote: On 29/07/2011 19:27, simendsjo wrote: On 29.07.2011 19:13, Simon wrote: On 29/07/2011 11:14, simendsjo wrote: Not sure how I can search for symbols in the library, but it seems the library is missing functions. I've

Re: Replacing hex values in a string (v1.0)

2011-08-12 Thread torhu
On 12.08.2011 18:19, jicman wrote: Greetings and salutations. Hi. I am reading a file into a string, char[] text = cast(string) f0.read(); and I want to replace every non-breaking space in the string. I know that the hex value for that is A0, but when I do this call, text = std.string.rep

Re: Symbol undefined due to import statement

2011-08-15 Thread torhu
On 15.08.2011 10:15, Andre wrote: ... I compile the application with command: dmd -IC:\Projects\Reusuable main.d This works, but if I now edit the http.d file and add an import statement like "import std.stdio;" then the linker will output following error: main.obj(main) Error 42: Symbol

Re: Memory leak with BufferedFile?

2011-08-29 Thread torhu
On 28.08.2011 01:00, Leon wrote: I'm writing a simple program which uses merge sort to sort very large text files. I split the text file into several temporary files which are sorted and merged together. The trouble I'm having is that the BufferedFile class seems to have a memory leak. The memor

Re: linker errors with class

2008-10-26 Thread torhu
Mike Parker wrote: ... Denis Koroskin wrote: No, it shouldn't. You may implement function bodies in other modules and/or languages (in C, for example, just make sure names have proper mangling). Right, but it just feels wrong to me for constructors & destructors since they are a required par

Re: GLchar** problem

2008-10-30 Thread torhu
Saaa wrote: glshaderSource needs a GLchar** and all I get from cast(char[]) read(filename) is a single * How do I get this extra pointer ? :D The C code is: char *file; shader = glCreateShader(GL_FRAGMENT_SHADER); file = textFileRead("program.frag"); const char * filep = file; glShaderSource(

Re: GLchar** problem

2008-10-30 Thread torhu
Saaa wrote: Assuming the C code works, here's what you do in D. GLuint shader; shader=glCreateShader(GL_FRAGMENT_SHADER); char[] file=cast(char[])read(`program.frag`); char* filep = toStringz(file); glShaderSource(f, 1, &filep,null); erm.. ok, thanks :) Thought I tried this already. But, how

Re: Getting environment variables?

2008-11-23 Thread torhu
Christopher Wright wrote: Hey all, How do I get environment variables in a D program? I specifically want the path to a user's home folder. Ta muchly. I think the 'correct' way on Windows is to use SHGetSpecialFolderPathA. Something like this: char[MAX_PATH] buf; SHGetSpecialFolderPathA(n

Re: Cyclic Dependencies

2008-12-09 Thread torhu
Ellery Newcomer wrote: When I first started learning D I decided that a good way to learn it would be by porting a popular java api (mind, I didn't say intelligent), which came complete with a few cyclic dependencies. At the moment, I'm using GDC, and it refuses to swallow cyclic dependencies.

Re: .bat file to help compile easier - dmd/build

2009-01-03 Thread torhu
On 02.01.2009 22:21, Jarrett Billingsley wrote: On Fri, Jan 2, 2009 at 2:17 PM, Michael P. wrote: Okay, so right now, I'm making a small game(Mario) using DAllegro. I use build, and every time, I have to type this in to compile my progress: build mario alleg.lib Now, I know it's not a lot

Re: druntime

2009-01-16 Thread torhu
On 16.01.2009 15:39, Hoenir wrote: Are there any information about druntime? The D2.0 changelog states Phobos was split with v2.020 but there are no information about that for D1. I'm especially interested in using a library based on Tango while using Phobos in the application itself (e.g. using

Re: long compile time 2.023 (few lines of code)

2009-01-23 Thread torhu
On 23.01.2009 18:49, Saaa wrote: The following code takes too long to compile (I kill link.exe to stop it) dmd 2.023 bud -full - cleanup -- module project.main; import project.bug; void main() { } -- module project.bug; struct Struct { uint number; int[6] array; byte[9] array2; } Struc

Re: Example Attached

2009-02-11 Thread torhu
On 10.02.2009 19:51, Heinz wrote: Heinz Wrote: I attached a rar file with the sources just to see what i'm talking about. The example is from the DMD site. Included is the extern D (ok) and the extern C (fails). To compile open "compile.bat" and to run the programs use "run.bat". Try this: a

Re: how to initialize an array of struct

2009-02-12 Thread torhu
On 12.02.2009 15:16, Frits van Bommel wrote: bearophile wrote: westcity Wrote: But, the compiler report "Error: array initializers as expressions are not allowed". Then, how do I initialize an array of struct ? Move the definition out of main (note that ; after the struct isn't required)

Re: Dear toolchain...

2009-03-10 Thread torhu
On 10.03.2009 19:38, Simen Haugen wrote: Jarrett Billingsley wrote: On Tue, Mar 10, 2009 at 1:45 PM, Simen Haugen wrote: I'm waist deep in problems, and have no idea how to get up. I have a program that uses d1, dmd, tango, ddbi, dwt and dwin. Some time ago I discovered that the program w

Re: How to reduce compile times?

2009-03-21 Thread torhu
On 21.03.2009 19:50, grauzone wrote: Christopher Wright wrote: grauzone wrote: PS: another thing that possibly would bring a speed gain would be to make dsss compile the whole project in one run, instead of invoking a new dmd process for each source file. How do I need to change the rebuil

Re: No map file?

2009-03-23 Thread torhu
On 23.03.2009 10:02, Frank Benoit wrote: How can i make DMD (link/optlink) not to generate a map file? -L/NOM or -LNOMAP both seem not work. I don't know, but bud manages this somehow, so Derek Parnell might know.

Re: New to D: Building multiple files

2009-03-29 Thread torhu
On 29.03.2009 17:04, chris wrote: Alright so I'm not too familiar with building D or having to build multiple files from the command line (Java usually takes care of that). Basically I have a small game I put together as a test project. Here's the structure: clo/clo.d clo/Main.d clo/common/Game

Re: Can somebody explain this memory usage

2009-04-03 Thread torhu
On 03.04.2009 11:34, Saaa wrote: What is the resident set size called in winXP taskmanager (Or: which other application should I use to check memory usage)? How can I chek memory stats? D1-phobos Thanks I believe 'Mem usage' is the resident size. I often use Process Explorer for tracking mem

Re: minimal evaluation

2009-04-06 Thread torhu
On 06.04.2009 13:30, Qian Xu wrote: Hi All, Is minimal evaluation always enabled in D? I want to write a function IsNull(), so that I can check the precondition as follows: if (isNull(foo) || isNull(foo.getBar) || isNull(foo.getBar.getBar2) { return false; } // n

Re: dmd 2.029 gtkD weird error.

2009-04-21 Thread torhu
On 22.04.2009 01:03, zkp0s wrote: |||Ups, wrong newsgroup.||| um.. anyway, is there any rules or whatever about the newsgroups.¿What to do if you post on a wrong newsgroup? Just post again, no the right newsgroup. If possible, delete the post first.

Re: Tango Jake or other build system for Linux

2009-06-14 Thread torhu
On 14.06.2009 17:16, Michal Minich wrote: I would like to compile programs on Linux using LDC and Tango using similar tool as is bundled with Windows version of Tango - jake.exe. This build tool is not included in Linux version of Tango and I'm not able to find it's source code anywhere. Is ther

Re: There is not std.stdio.flush

2009-07-20 Thread torhu
On 20.07.2009 17:01, Haruki Shigemori wrote: uhmm... I think std.c.stdio is a port of the C language library, std.stdio must has flush or fflush as the D language library. It's not a port, it _is_ the std C library. std.stdio just adds functionality on top of what C provides. That's what Phob

Re: Execute process and read its stdout/stderr asynchronously

2009-07-22 Thread torhu
On 22.07.2009 10:41, kkll wrote: I'm trying out D2+phobos on OSX and would like to write wrapper around few shell commands. I've found only very basic exec() and system() in std lib, but I need to launch few things at once and get all their output. Is there something like Cocoa's NSTask in D?

Re: D2 Win API Problem

2009-09-20 Thread torhu
On 20.09.2009 20:11, A Bothe wrote: Hello guys, I got a problem with the following code. I can compile it successfully but when I want to start it, there is just this "object.AccessVialotion"! Even GetLastError() returns 0 so the problem cannot be found in wrong-written names... Thanks in

Re: D2 Win API Problem

2009-09-21 Thread torhu
On 21.09.2009 17:11, A Bothe wrote: I solved the problem! I've to make the function pointer to be extern(C), so I will have extern(C) { int function(...) tfunc; } MessageBoxA is definitely stdcall, so extern (Windows) is correct. So the problem has to be something else.

Re: Problems linking C and D code

2009-10-24 Thread torhu
On 24.10.2009 15:02, Jan Stępień wrote: Hi all, I've got a problem with linking two object files on Windows with an external *.lib file. First one is compiled C code, second one is in D. I'm using D2. $ dmc -c first.c -I path/to/SDL/include $ dmd -c second.d First two commands create two

Re: Problems linking C and D code

2009-10-24 Thread torhu
On 24.10.2009 16:17, Jan Stępień wrote: On Sat, 24 Oct 2009 15:56:05 +0200 torhu wrote: On 24.10.2009 15:02, Jan Stępień wrote: > Hi all, > > I've got a problem with linking two object files on Windows with an > external *.lib file. First one is compiled C code, s

Re: error linking to my own custom module

2009-11-10 Thread torhu
On 11.11.2009 04:57, Sean Fennell wrote: I'm very green to D, just learning it now. I have a module that I wrote. Its pretty simple, just helper functions to get input from user as certain data types GetInt() GetString() GetChar() etc... I compiled the module using dmd -lib mymod.d which outpu

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

2009-11-15 Thread torhu
On 15.11.2009 08:53, g wrote: I have been trying to actualize the http://www.dsource.org/projects/dallegro binings to the lastest D2 version. The main problems are: *TLS *volatile isn't here anymore ( neither with -d ) You can remove volatile by just building with -version=NoVolatile. But I

Re: Undefined __moduleUnitTests

2009-12-19 Thread torhu
On 18.12.2009 8:23, Brian Eyster wrote: I get the following message when trying to compile the winsamp.d code: OPTLINK (R) for Win32 Release 8.00.2 Copyright (C) Digital Mars 1989-2009 All rights reserved. http://www.digitalmars.com/ctg/optlink.html winsamp.obj(winsamp) Error 42: Symbol Undef

Re: Undefined __moduleUnitTests

2009-12-21 Thread torhu
On 21.12.2009 3:45, Brian Eyster wrote: I am running the compiler located in C:\dmd2\windows\bin\. In the readme.txt file it gives the following info for the compiler: "dmd.exe D compiler http://www.digitalmars.com/d/2.0/dmd-windows.html"; In the sc.ini file in the same directory is gives: "[Ver

Template function alias that leaves out the last type parameter

2022-09-27 Thread torhu via Digitalmars-d-learn
How would I achieve something like this, do I have to turn the aliases into functions? ```d void _messageBox(string title, int style, T...)(T args) { string s = format(args); /* etc... */ } alias _messageBox!(APPNAME, SWT.ICON_INFORMATION) info; alias _messageBox!("Warning", SWT.ICON_WA

Re: Template function alias that leaves out the last type parameter

2022-09-27 Thread torhu via Digitalmars-d-learn
On Tuesday, 27 September 2022 at 22:39:52 UTC, torhu wrote: How would I achieve something like this, do I have to turn the aliases into functions? ```d void _messageBox(string title, int style, T...)(T args) { string s = format(args); /* etc... */ } alias _messageBox!(APPNAME

Re: Template function alias that leaves out the last type parameter

2022-09-27 Thread torhu via Digitalmars-d-learn
On Tuesday, 27 September 2022 at 23:18:06 UTC, Adam D Ruppe wrote: On Tuesday, 27 September 2022 at 22:39:52 UTC, torhu wrote: How would I achieve something like this, do I have to turn the aliases into functions? You can write it out long-form with two steps like this: Thank you, works

Re: Template function alias that leaves out the last type parameter

2022-09-28 Thread torhu via Digitalmars-d-learn
On Wednesday, 28 September 2022 at 12:43:52 UTC, rassoc wrote: On 9/28/22 02:04, torhu via Digitalmars-d-learn wrote: Thank you, works like a charm! It does? How are you formatting `info("foo", 'a', 42)` inside the template if I may ask? It works like writefln, so th

Replacing tango.text.Ascii.isearch

2022-10-05 Thread torhu via Digitalmars-d-learn
I need a case-insensitive check to see if a string contains another string for a "quick filter" feature. It should preferrably be perceived as instant by the user, and needs to check a few thousand strings in typical cases. Is a regex the best option, or what would you suggest?

Re: Replacing tango.text.Ascii.isearch

2022-10-05 Thread torhu via Digitalmars-d-learn
On Wednesday, 5 October 2022 at 17:29:25 UTC, Steven Schveighoffer wrote: [...] I wanted to do some quick benchmarking to figure out what works. When I run this: ```d import std.stdio; import std.datetime.stopwatch; void main() { auto sw = StopWatch(); sw.stop(); wr

Re: Replacing tango.text.Ascii.isearch

2022-10-05 Thread torhu via Digitalmars-d-learn
On Wednesday, 5 October 2022 at 20:40:46 UTC, torhu wrote: Am I doing something wrong here? Right, you can instantiate structs without arguments. It's been ten years since I last used D, I was thinking of structs like if they were classes.

Re: Replacing tango.text.Ascii.isearch

2022-10-05 Thread torhu via Digitalmars-d-learn
On Wednesday, 5 October 2022 at 20:45:55 UTC, torhu wrote: On Wednesday, 5 October 2022 at 20:40:46 UTC, torhu wrote: Am I doing something wrong here? Right, you can instantiate structs without arguments. It's been ten years since I last used D, I was thinking of structs like if they

Re: Replacing tango.text.Ascii.isearch

2022-10-05 Thread torhu via Digitalmars-d-learn
On Wednesday, 5 October 2022 at 17:29:25 UTC, Steven Schveighoffer wrote: ```d bool isearch(S1, S2)(S1 haystack, S2 needle) { import std.uni; import std.algorithm; return haystack.asLowerCase.canFind(needle.asLowerCase); } ``` untested. -Steve I did some basic testing, and regex

Re: Replacing tango.text.Ascii.isearch

2022-10-06 Thread torhu via Digitalmars-d-learn
On Thursday, 6 October 2022 at 21:36:48 UTC, rassoc wrote: And what kind of testing was that? Mind to share? Because I did the following real quick and wasn't able to measure a "two orders of magnitude" difference. Sure, the regex version came on top, but they were both faster than the ruby ba

Re: Doubt about char.min/max == typeid(char)

2022-10-06 Thread torhu via Digitalmars-d-learn
On Friday, 7 October 2022 at 00:13:59 UTC, matheus wrote: Hi, Could anyone please tell me why the properties of min/max of a char returns a "char type" and not a value as an int? Well, why whould the highest and lowest values of a type be of a different type..? ```d import std; void func

aa.keys, synchronized and shared

2022-11-10 Thread torhu via Digitalmars-d-learn
I'm trying to make a more thread-safe wrapper for AA's: ``` synchronized final class SyncAA(K, V) /// { /// V opIndex(K key) { return data_[key]; } /// V opIndexAssign(V value, K key) { return data_[key] = value; } /// K[] keys() const { return data_.keys; } ///

Re: aa.keys, synchronized and shared

2022-11-10 Thread torhu via Digitalmars-d-learn
On Thursday, 10 November 2022 at 21:55:26 UTC, torhu wrote: I'm trying to make a more thread-safe wrapper for AA's: ``` synchronized final class SyncAA(K, V) /// I chose to fix this by just using `synchronized (this)` inside each method instead, for now. Still interested

Re: aa.keys, synchronized and shared

2022-11-11 Thread torhu via Digitalmars-d-learn
On Friday, 11 November 2022 at 14:19:31 UTC, Kagamin wrote: Try this: ``` private: V[K] sharedTable; ref inout(V[K]) unsharedTable() inout { return *cast(inout(V[K])*)&sharedTable; } ``` Thanks, that worked! Feels like programming in C, though.

Re: aa.keys, synchronized and shared

2022-11-14 Thread torhu via Digitalmars-d-learn
On Monday, 14 November 2022 at 07:57:16 UTC, Kagamin wrote: This works for me: ``` shared SyncAA!(string,string) saa; void f() { saa=new shared SyncAA!(string,string)("1","2"); saa.keys(); saa["12"]="34"; saa.remove("12"); } ``` The strange error message I got wa

Re: How to use version in dub?

2022-12-13 Thread torhu via Digitalmars-d-learn
On Tuesday, 13 December 2022 at 19:28:44 UTC, Leonardo A wrote: Hello. How to use version in dub? https://dlang.org/spec/version.html "The version level and version identifier can be set on the command line by the -version" I tried everything but noting. In SDL syntax, either at the top lev

Re: How to use version in dub?

2022-12-13 Thread torhu via Digitalmars-d-learn
On Tuesday, 13 December 2022 at 19:50:15 UTC, torhu wrote: On Tuesday, 13 December 2022 at 19:28:44 UTC, Leonardo A wrote: Hello. How to use version in dub? https://dlang.org/spec/version.html "The version level and version identifier can be set on the command line by the -version"

Is there such a JSON parser?

2023-01-01 Thread torhu via Digitalmars-d-learn
I need to parse some JSON data into various data structures, so I'm looking for a parser based on events or ranges. One that doesn't just load the file and build a data structure that represents the whole thing. So not std.json, at least.

Re: Is there such a JSON parser?

2023-01-02 Thread torhu via Digitalmars-d-learn
On Monday, 2 January 2023 at 05:44:33 UTC, thebluepandabear wrote: You might want to try the following: https://github.com/libmir/asdf I had a look at that, but I think it just loads the whole file into it's own data structure. And then you can use attributes to get it to fill structs with d

Re: Is there such a JSON parser?

2023-01-02 Thread torhu via Digitalmars-d-learn
On Monday, 2 January 2023 at 14:56:27 UTC, SealabJaster wrote: Are you asking for a SAX-styled parser for JSON? Yes, I actually want to replace a SAX parser.

Re: Handling CheckBox state changes in DLangUI

2023-01-02 Thread torhu via Digitalmars-d-learn
On Saturday, 31 December 2022 at 02:40:49 UTC, Daren Scot Wilson wrote: The compiler errors I get are, for no '&' and with '&': Error: function `app.checkbox_b_clicked(Widget source, bool checked)` is not callable using argument types `()` Error: none of the overloads of `opAssign` are calla

Re: Is there such a JSON parser?

2023-01-02 Thread torhu via Digitalmars-d-learn
On Monday, 2 January 2023 at 21:36:10 UTC, Steven Schveighoffer wrote: On 1/1/23 6:28 PM, torhu wrote: I need to parse some JSON data into various data structures, so I'm looking for a parser based on events or ranges. One that doesn't just load the file and build a data struc

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-01-20 Thread torhu via Digitalmars-d-learn
On Friday, 20 January 2023 at 11:28:23 UTC, thebluepandabear wrote: Hi, In Java/C# you can create purely static classes. These are classes whose methods are all static, the classes cannot be derived from or instantiated: ``` static class Algo { void drawLine(Canvas c, Pos from, Pos to) {