Re: Replace (ie: substitute) a type in varadic args

2016-08-02 Thread Sean Campbell via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 07:24:28 UTC, Saurabh Das wrote: How can I substitute the type of an argument received via a varadic template? For example say I want to generalise this scenario: auto myConverterFunction1(bool arg1, bool arg2, ubyte arg3, int arg4) { return

Re: winsamp.d dont compiler.

2016-07-31 Thread Sean Campbell via Digitalmars-d-learn
On Sunday, 31 July 2016 at 23:36:54 UTC, Cassio Butrico wrote: in C:\d\dmd2\samples\d winsamp.d dont compiler. dmd winsamp gdi32.lib winsamp.def winsamp.d(53): Error: function core.sys.windows.winuser.LoadIconA (void*, const(char)*) is not callable using argument types (typeof(null), wchar*)

Re: What is the best way to stop App after exception?

2016-02-15 Thread Sean Campbell via Digitalmars-d-learn
On Monday, 15 February 2016 at 11:38:05 UTC, Suliman wrote: I have got class Config with method parseconfig. I need terminate App if parsing of config was failed. The problem that I do not know how to do it better. void parseconfig() { try { //something go wrong } catch(Exception e) {

Re: std.zip for Binary example

2016-01-17 Thread Sean Campbell via Digitalmars-d-learn
On Sunday, 17 January 2016 at 10:34:19 UTC, locco wrote: Hi :) I found this example: == import std.file: write; import std.string: representation; void main() { char[] data = "Test data.\n".dup; // Create an ArchiveMember

What is the corect behavour for lazy in foreach variadic template

2015-09-25 Thread Sean Campbell via Digitalmars-d-learn
Take the following code for example module test; import std.stdio; void test(T...)(lazy T args) { foreach(arg;args) //bar is invoked here { writeln("about to process arg"); writefln("processing arg %s",arg); //but it should be invoked here, right? } }

Re: Exec function D from C++

2015-06-21 Thread Sean Campbell via Digitalmars-d-learn
On Sunday, 21 June 2015 at 13:12:03 UTC, MGW wrote: Linux 32, dmd 2.067.0 I want to connect and execute function D from main() C++. d1.d import core.stdc.stdio; extern (C++) void d1() { printf(printf - exec d1()); } main_c1.cpp #include stdio.h void d1(void); int

using pipeprocess on non-applications

2014-07-26 Thread Sean Campbell via Digitalmars-d-learn
is there any way to detect if a file is a binary executable that is cross platform or a way to detect whether pipeprocss failed to execute a file if it wasn't executable.

zlibs gzip dosent work with http

2014-07-24 Thread Sean Campbell via Digitalmars-d-learn
I'm trying to add gzip compression to a HTTP server i wrote in D. here is the code that dose the gzip encoding. if ((Info.modGzip) (indexOf(client.getRequestHeaderFieldValue(Accept-Encoding),gzip) != -1)){ writeln(gzip); auto gzip = new Compress(HeaderFormat.gzip);

Re: get os thread handles

2014-07-20 Thread Sean Campbell via Digitalmars-d-learn
On Sunday, 20 July 2014 at 09:53:52 UTC, Jonathan M Davis wrote: On Sunday, 20 July 2014 at 09:34:46 UTC, Sean Campbell wrote: How do i get an os thread handle from a thread object. or are d thread not wrapped os threads. They do wrap OS threads, but they encapsulate them in a cross-platform

is there any way for an object to make it self no longer usable

2014-07-19 Thread Sean Campbell via Digitalmars-d-learn
is there any way for an object to make it self no longer usable? eg class someclass { string somevalue; bool someflag; int somelength; this (value,length,flag) { somevalue = value; someflag = flag; somelength =

Re: is there any way for an object to make it self no longer usable

2014-07-19 Thread Sean Campbell via Digitalmars-d-learn
On Saturday, 19 July 2014 at 13:46:08 UTC, Kagamin wrote: You can encapsulate it in a wrapper, which will control access to the object and reject if necessary. how ? surely not by writing another class with wrapper methods for the existing one.

md5 hashing acting strangly?

2014-07-16 Thread Sean Campbell via Digitalmars-d-learn
i have the following code char[] Etag(string file){ auto info = DirEntry(file); ubyte[16] hash = md5Of(to!string(info.timeLastAccessed.day)~ to!string(info.timeLastAccessed.month)~

phobos iterate through json subkeys?

2014-07-15 Thread Sean Campbell via Digitalmars-d-learn
How Can I Iterate through JSON Subkeys using std.json? Or Do I Have To Use An External Library For that

Raw Binary into the console

2014-07-12 Thread Sean Campbell via Digitalmars-d-learn
How Can I Print Raw Binary Into The Console? I Have Variable Of Type ubyte which equals 0b011 How Can I Get The Variable To Print Out As 011

Re: Concatenates int

2014-07-10 Thread Sean Campbell via Digitalmars-d-learn
perhaps I'd better state what I'm doing. i have an array of 4 bytes and a want to convert them to a 32 bit int and convert the 32 bit int back into a 4 bytes again.

Re: Concatenates int

2014-07-10 Thread Sean Campbell via Digitalmars-d-learn
On Thursday, 10 July 2014 at 13:51:22 UTC, Rikki Cattermole wrote: On 11/07/2014 1:18 a.m., Sean Campbell wrote: perhaps I'd better state what I'm doing. i have an array of 4 bytes and a want to convert them to a 32 bit int and convert the 32 bit int back into a 4 bytes again. Small hack I

Re: Concatenates int

2014-07-10 Thread Sean Campbell via Digitalmars-d-learn
On Thursday, 10 July 2014 at 15:51:11 UTC, Olivier Pisano wrote: Hello, I may have not understood what you actually want to do, but aren't std.bitmanip.peek or std.bitmanip.read what you are looking for ? http://dlang.org/phobos/std_bitmanip.html#.peek std.bitmanip.peek and std.bitmanip.read

What am I doing Wrong (OpenGL SDL)

2014-07-04 Thread Sean Campbell via Digitalmars-d-learn
I cannot figure out what is wrong with this code and why i keep getting object.error access violation. the code is simple tutorial code for SDL and OpenGL what am i doing wrong (the access violation seems to be with glGenBuffers) The Code import std.stdio; import derelict.opengl3.gl3; import

Re: What am I doing Wrong (OpenGL SDL)

2014-07-04 Thread Sean Campbell via Digitalmars-d-learn
On Friday, 4 July 2014 at 08:02:59 UTC, Misu wrote: Can you try to add DerelictGL3.reload(); after SDL_GL_CreateContext ? yes this solved the problem. however why? is it a problem with the SDL binding?

Exception style

2014-06-25 Thread Sean Campbell via Digitalmars-d-learn
i know you can use both throw new Exception(msg); and module test; class testException { this (string msg) { super(some error info : ~msg); } } throw new testException(msg); but which one is better conforms to the d style?

Re: Exception style

2014-06-25 Thread Sean Campbell via Digitalmars-d-learn
On Wednesday, 25 June 2014 at 09:54:16 UTC, bearophile wrote: Sean Campbell: but which one is better conforms to the d style? Both are valid. Use the second when you want a more precise exception in your code, this is common in larger programs. Keep in mind that you can allocate an