Handling exceptions from Windows DLL

2013-09-12 Thread FreeSlave
Hello. There was an issue 2 years ago: https://github.com/D-Programming-Language/druntime/pull/92 It seems that this bug is still here (I can't handle D Exception from dll builded with dmd and dmc link). Will this bug get fixed? Do other D compilers have the same issue?

Re: Adding libraries to an executable

2013-09-13 Thread FreeSlave
On Friday, 13 September 2013 at 19:54:41 UTC, Anton Alexeev wrote: So, nobody can give an easy answer how to statically link the libraries with the executable and I have yo use Bin2D? Did you try to use -static option of compiler? It forces to link application with static libraries instead of

Module to work with environment variables

2013-09-14 Thread FreeSlave
As I remember there was module to work with environment variables in standard library. But now I can't find it. Was it removed or merged with some other module? Another question: I see some of modules are considered out-dated and not up to Phobos' current standards. Can I make attempt to

Type inference and overloaded functions

2013-12-09 Thread FreeSlave
I just found weird D behavior about inference of array types. Let's suppose we have these overloaded functions: import std.stdio; void bar(const(int[3]) arr) { writeln(static array); } void bar(const(int[]) arr) { writeln(array slice); } // In main we have something like that: int

Constructor performance in dmd

2013-12-10 Thread FreeSlave
Hello, I wrote some performance test for different constructors of simple struct, and got some unexpected results. Code: //dmd vector.d -unittest module vector; debug(SVector) { import std.stdio; } struct SVector(size_t dim, T = float) { private: T[dim] _arr; public: alias dim

Re: Python calling D

2013-12-11 Thread FreeSlave
On Wednesday, 11 December 2013 at 05:30:49 UTC, CJS wrote: I'd like to use cython to wrap a D library. It's possible to do this with a statically compiled C library, but it fails when I try with a statically compiled D library. Any suggestions on how to do this successfully? I'm not Cython

writeln calls postblits constructor four times before print

2013-12-11 Thread FreeSlave
Code: module vector; import std.stdio; import std.traits; struct SVector(size_t dim, T = float) { private: T[dim] _arr; public: alias dim dimension; alias dim size; this(this) { debug(SVector) writeln(postblit constructor); } this(const T[dim]

Re: Question about function aliases

2013-12-12 Thread FreeSlave
On Thursday, 12 December 2013 at 11:11:55 UTC, bearophile wrote: Gary Willoughby: alias void function(ClientData clientData, Tcl_Interp* interp) Tcl_InterpDeleteProc; extern (C) void Tcl_CallWhenDeleted(Tcl_Interp* interp, Tcl_InterpDeleteProc proc, ClientData clientData); With recent D

Re: A good advertisement for 'static if'

2013-12-12 Thread FreeSlave
On Thursday, 12 December 2013 at 14:55:28 UTC, Craig Dillabaugh wrote: I am not sure if this belongs in D.learn, but it might be of interest. I was writing some C++ code for a project at work and have a class that stores image data from a file. The image data can be in just about any numeric

Re: A good advertisement for 'static if'

2013-12-12 Thread FreeSlave
With some improvements you also can provide compile-time error about instantiation of non-specialized function (i.e. which has T as parameter), but I'm not sure what's good way to do it in C++.

Strict capacity of array

2013-12-13 Thread FreeSlave
Suppose some class contains slice (dynamic array) as data member. Constructor takes integer value that defines the size of data should be allocated. After object was constructed size of slice never changes by design. Dynamic arrays are allocated with extra space that we can know from

Re: Strict capacity of array

2013-12-13 Thread FreeSlave
Thanks for answers. On Friday, 13 December 2013 at 19:35:01 UTC, Marco Leise wrote: Have you tried this?: import core.memory; int[] data = (cast(int*)GC.malloc(size * int.sizeof, GC.BlkAttr.NO_SCAN))[0 .. size]; Did you mean GC.BlkAttr.NONE maybe? If I get it right GC.BlkAttr.NO_SCAN means

Re: Compilation depends on class methods order

2013-12-20 Thread FreeSlave
Make first read function templated too like this: long read()( ubyte* bytes, long len )

Re: Ultra-pure map()?

2013-12-28 Thread FreeSlave
On Saturday, 28 December 2013 at 09:18:00 UTC, David Held wrote: On 12/27/2013 7:32 PM, Marco Leise wrote: [...] Side effects and altering the input object itself makes me want to pull out my crucifix. You shall not have impurity in your functional style code! Why not? There are many impure

Re: lexer/parser library for D

2013-12-29 Thread FreeSlave
There is also http://www.semitwist.com/goldie/ but I did not use it.

Re: lexer/parser library for D

2013-12-29 Thread FreeSlave
On Sunday, 29 December 2013 at 19:25:46 UTC, Jonathan wrote: Are there any good lexer and parser libraries (like flex/bison) for D? If not, how much work would be involved in using flex and bison and wrapping it to D? How straightforward is it to pass a struct from C to D (the documentation

Re: VC linker - unresolved external symbols - runtime

2014-01-05 Thread FreeSlave
On Sunday, 5 January 2014 at 19:05:58 UTC, Erik van Velzen wrote: @Palmic the DWinProgramming samples use the overload Runtime.initialize(ExceptionHandler) Which gives a warning that it is deprecated and you should use this overload instead: Runtime.initialize() But this is not compiled in

Re: Shared library extern (C) variables

2014-01-05 Thread FreeSlave
On Sunday, 5 January 2014 at 18:22:54 UTC, Mineko wrote: I keep getting mixed results searching for this. :\ Just as the title says, is it safe to extern (C) variables? Something like this: extern (C) auto foo = 800; And then call that from another program? Also, just because this has been

Re: VC linker - unresolved external symbols - runtime

2014-01-05 Thread FreeSlave
On Sunday, 5 January 2014 at 19:30:46 UTC, Erik van Velzen wrote: Filed under installer https://d.puremagic.com/issues/show_bug.cgi?id=11871 You could add the linux thing as a comment if you're sure it's the same issue. Well, I'm not sure this is same. I explored something new to me and

libphobos.so and loading libraries at runtime

2014-01-05 Thread FreeSlave
import core.runtime; int main() { Runtime.loadLibrary(does not care); Runtime.unloadLibrary(null); return 0; } When I try to compile this code with 'dmd main.d', I get errors main.o: In function `_D4core7runtime7Runtime17__T11loadLibraryZ11loadLibraryFxAaZPv':

Re: dirEntries throws exception on broken symlinks

2014-01-05 Thread FreeSlave
You must not cast base class to derived class, when you don't know actual type (and even if you know exact type it's still bad practice to cast instance of more generic type to more specific one). Use multiple catch statements instead: catch(FileException o) { //handle FileException }

Re: singleton with momento

2014-01-10 Thread FreeSlave
On Thursday, 9 January 2014 at 21:51:46 UTC, Frustrated wrote: Lets suppose I have setup some code to use a singleton object. Now lets suppose I want to duplicate that code(say to run multiple times simultaneously). The singleton pattern itself prevents multiple copies. One would need

Re: Any library with string encoding/decoding support?

2014-01-21 Thread FreeSlave
iconv as library is under LGPL. iconv as utility is under GPL. Note that iconv is not portable even on Linux, since different distros may have different implementations. Qt is not the case because it's unstable with D. It's also redundant dependency. And as far as I know Qt uses

Re: User defined types: Problems with ref

2014-01-23 Thread FreeSlave
On Thursday, 23 January 2014 at 15:24:19 UTC, Chris wrote: Here's what I'm trying to do. struct Element(T) { T x; T y; public void setX(T value) { x = value; } // More fancy functions ... } I store Element(s) in an array and want to pass each one by reference, which

Re: User defined types: Problems with ref

2014-01-23 Thread FreeSlave
On Thursday, 23 January 2014 at 15:24:19 UTC, Chris wrote: Thanks, that was fast! Yes I was tinkering around with pointers, but didn't get it right, you did. However, the output is still the same, i.e. two different sets: // After creating and changing div id=1 Hello, world! span /span /div

Re: User defined types: Problems with ref

2014-01-23 Thread FreeSlave
Anyway, why do you need pointers to elements?

Re: immutable int n = Test(); int[n] x;---- compiles, but __ctfe is false. How?

2014-02-21 Thread FreeSlave
On Friday, 21 February 2014 at 13:38:58 UTC, Gopan wrote: Attempting to learn CTFE, I tried the following test. size_t counter; uint Test() { if (!__ctfe) { ++counter;// This code is for execution at run time } return 2; } void main() {

Re: immutable int n = Test(); int[n] x;---- compiles, but __ctfe is false. How?

2014-02-21 Thread FreeSlave
Another strange thing: import std.stdio; uint Test() { if (!__ctfe) { return 3; } return 2; } void main() { immutable n = Test(); int[n] arr; writeln(arrary length = , arr.length, ; n = , n); } Output: arrary length = 2 ; n = 3 When you think about it

Re: How to install dmd2 in centos 5.3 x64

2014-02-25 Thread FreeSlave
It's not dmd problem, it's up to ld linker and the issue is same for other compiled languages including C and C++. You should specify LD_LIBRARY_PATH variable in your system before executing any compiled D application. You can add export of this environment variable to your $HOME/.profile or

Re: Nobody understands templates?

2014-02-28 Thread FreeSlave
Well, when you're starting to use many templates you may end up with separate library. Templates provide compile-time correctness, concepts (in Boost sense), policy-base design (see Modern C++ Design: Generic Programming and Design Patterns Applied by Andrei Alexandrescu) and compile-time

Re: mutable reference to const object

2014-03-06 Thread FreeSlave
You probably need Rebindable template from std.typecons.

Re: mutable reference to const object

2014-03-06 Thread FreeSlave
Yes, in some cases C++ const does not provide const-guarantees, it's more like convention. For example, you can write this: class Class { public: Class() : ptr(new int()) {} ~Class() { delete ptr; } void setData(int data) const { *ptr = data; } private: int *ptr; };

Re: D to C++ DLL

2014-03-13 Thread FreeSlave
long in D and long in C++ are different types. You should use c_long from core.stdc.config to interface with C/C++ functions.

Re: How do I obtain the default hash of a user-defined struct

2014-04-02 Thread FreeSlave
On Wednesday, 2 April 2014 at 20:14:31 UTC, dnspies wrote: How can I get the default-hash of a struct I've defined (to be used as part of the hash for some containing type)? UserDefined userDefined; writeln(typeid(UserDefined).getHash(userDefined)); Probably there is a better way. I don't

Re: Sockets between D and C(++) app

2014-04-02 Thread FreeSlave
It's only server. Maybe problem is on client side. Try this if you are on Linux: //Linux C client #include sys/socket.h #include sys/types.h #include netinet/in.h #include arpa/inet.h #include stddef.h #include string.h #include stdio.h int main() { int sock, res; struct sockaddr_in

Re: How do I obtain the default hash of a user-defined struct

2014-04-02 Thread FreeSlave
Contents of struct are compared field by field using comparison for the type of each field. Dynamic arrays are compared by contents. If you want to compare them by pointer use .ptr property. opEquals and opCmp are not about hashing, I believe. They are just operators to help when dealing

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread FreeSlave
On Wednesday, 16 April 2014 at 17:47:05 UTC, Capture_A_Lag wrote: Hi all! I have this code: -- ubyte N, M, K; ubyte[][max][max] Matrix; scanf(%d %d %d, N, M, K); ubyte tmp; for(ubyte n = 1; n = N; n++)

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread FreeSlave
Note that readf is not equivalent to scanf since readf does not skip spaces and newline character. Input must completely match format.

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread FreeSlave
It also throws if you input initial or trailing spaces and there are no spaces at the start or end of format string (scanf skips these spaces)

Re: Get and set terminal size

2014-04-19 Thread FreeSlave via Digitalmars-d-learn
What are compiler and platform do you use? Probably you are trying to link with 64-bit library while being on 32-bit OS (or vice versa) It works fine on my 32-bit Debian with ldc2 and dmd.

Re: Get and set terminal size

2014-04-19 Thread FreeSlave via Digitalmars-d-learn
I use ldc2 main.d -L-lcurses or dmd main.d -L-lcurses and following source code: import std.stdio; extern(C) int tgetnum(const(char) *id); int main() { writeln(tgetnum(li)); return 0; } Note that you don't need to apply toStringz to string literals since they implicitly cast to

Re: why can't I call const methods on shared objects?

2014-05-11 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 11 May 2014 at 07:31:10 UTC, FreeSlave wrote: On Friday, 9 May 2014 at 21:42:14 UTC, Vlad Levenfeld wrote: Is this still the case if the method is const or pure? Const methods still require synchronization, because other threads may change some data, needed by const method while

Re: why can't I call const methods on shared objects?

2014-05-11 Thread FreeSlave via Digitalmars-d-learn
On Friday, 9 May 2014 at 21:42:14 UTC, Vlad Levenfeld wrote: Is this still the case if the method is const or pure? Const methods still require synchronization, because other threads may change some data, needed by const method while method is executed, and then you may get wrong results.

Re: Configuring Phobos from the 1-click installer

2014-05-11 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 11 May 2014 at 05:34:38 UTC, Moses wrote: On Sunday, 11 May 2014 at 04:33:24 UTC, Ali Çehreli wrote: On 05/10/2014 07:12 PM, Moses wrote: After using the 1-click Ubuntu installer, I'm having trouble figuring out how to import standard library functions for Phobos. I get the

Re: Temporary silence output (stdout)

2014-05-11 Thread FreeSlave via Digitalmars-d-learn
On Saturday, 10 May 2014 at 20:24:50 UTC, MarisaLovesUsAll wrote: Hi! I sometimes got a useless messages in stdout from SDL_Image library, and I want to temporary silence it. How do I do? You can temporary redirect output to file. Example (on C): #include stdio.h #include unistd.h #include

Re: Messy code in console

2014-05-11 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 11 May 2014 at 07:43:07 UTC, Kagamin wrote: Known bug https://issues.dlang.org/show_bug.cgi?id=2742 It's not bug. Write-functions are designed to output text to stdout, and it's issue of programmer to make sure that expected acceptor can interpret them properly. Note that stdout

Re: Can't link libs?

2014-06-08 Thread FreeSlave via Digitalmars-d-learn
On Friday, 6 June 2014 at 16:33:27 UTC, Adam D. Ruppe wrote: When you compile the final program, the library .d file needs to be available too, either in the folder based on its name or passed straight to dmd explicitly. Despite the presence of the .lib file, the .d file is still needed so

Re: crt1.o: could not read symbols: Bad value

2014-06-10 Thread FreeSlave via Digitalmars-d-learn
dmd has -shared option. Try it instead of -L-shared.

Re: crt1.o: could not read symbols: Bad value

2014-06-11 Thread FreeSlave via Digitalmars-d-learn
It seems like you're trying to compile 64-bit code when you are on 32-bit system and you have 32-bit libphobos.

Re: crt1.o: could not read symbols: Bad value

2014-06-11 Thread FreeSlave via Digitalmars-d-learn
I conclude that because I have similar errors when trying to build 64-bit library on 32-bit system. /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(format_712_5b3.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC

Re: Subclass of Exception

2014-06-14 Thread FreeSlave via Digitalmars-d-learn
On Saturday, 14 June 2014 at 11:59:53 UTC, Paul wrote: One stupid question: in Python subclassing of Exception looks like: class MyError(Exception): pass but in D, if I'm right, we should write more code: class MyError : Exception { this(string msg) { super(msg); } } (without

Re: Subclass of Exception

2014-06-15 Thread FreeSlave via Digitalmars-d-learn
I don't think you always need documentation for all exception classes, since the most of them have the same interface. Usually it's worth to describe where is some exception able to be thrown from, not exception itself. And it's covered by function documentation, not by documentation of

dub --annotate option

2014-06-19 Thread FreeSlave via Digitalmars-d-learn
Dub has option called --annotate. It's described like this: Do not perform any action, just print what would be done I supposed it's something similar to -n option of Jam build system (I really like this feature). But dub's annotate prints nothing. So what is that? I have DUB version 0.9.21

Re: Passing around a list of differently typed functions

2014-06-23 Thread FreeSlave via Digitalmars-d-learn
On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote: As the subject says, I would like to pass around an array of functions. The trick is, that the functions have different type signatures. Is there a way to put the two functions int foo(int a, int b); bool bar(bool a, bool b); into

Re: close program by code

2014-06-26 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 26 June 2014 at 09:05:23 UTC, pgtkda wrote: How can i close my application by code? Do you mean exit status? Just call exit function from C library. import std.c.stdlib; void main() { exit(0); }

Re: close program by code

2014-06-26 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 26 June 2014 at 11:07:37 UTC, Rene Zwanenburg wrote: On Thursday, 26 June 2014 at 10:40:00 UTC, John Colvin wrote: On Thursday, 26 June 2014 at 09:58:50 UTC, FreeSlave wrote: On Thursday, 26 June 2014 at 09:05:23 UTC, pgtkda wrote: How can i close my application by code? Do you

Re: DUB help plz

2014-07-03 Thread FreeSlave via Digitalmars-d-learn
Derelict contains bindings to other libraries, not these libraries themselves. dub downloads only these bindings, not original libraries (since they are written in C, not D, and not included in dub repositories). You should manually get necessary libraries and put them in folder where .exe

Re: fork/waitpid and std.concurrency.spawn

2014-07-22 Thread FreeSlave via Digitalmars-d-learn
On Tuesday, 22 July 2014 at 07:58:50 UTC, Puming wrote: Is there a fork()/wait() API similar to std.concurrency spawn()? The best thing I've got so far is module core.sys.posix.unistd.fork(), but it seems to only work in posix. Is there a unified API for process level concurrency? ideally

Re: How to know whether a file's encoding is ansi or utf8?

2014-07-22 Thread FreeSlave via Digitalmars-d-learn
Note that BOMs are optional and may be not presented in Unicode file. Also presence of leading bytes which look BOM does not necessarily mean that file is encoded in some kind of Unicode.

Re: fork/waitpid and std.concurrency.spawn

2014-07-22 Thread FreeSlave via Digitalmars-d-learn
:43:58 UTC, FreeSlave wrote: On Tuesday, 22 July 2014 at 07:58:50 UTC, Puming wrote: Is there a fork()/wait() API similar to std.concurrency spawn()? The best thing I've got so far is module core.sys.posix.unistd.fork(), but it seems to only work in posix. Is there a unified API for process

Re: Grabing C(++) stdout

2014-07-23 Thread FreeSlave via Digitalmars-d-learn
have to redirect it from within the C++ code. I've created simple example (for Linux) - https://bitbucket.org/FreeSlave/redirect-example/src It works as expected. Nothing writes to console, but to file.

Re: pointer array?

2014-07-31 Thread FreeSlave via Digitalmars-d-learn
On Wednesday, 30 July 2014 at 20:51:25 UTC, Daniel Kozak via Digitalmars-d-learn wrote: V Wed, 30 Jul 2014 14:33:51 + seany via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: In Ali's excllent book, somehow one thing has escaped my attention, and that it the mentioning of

Re: Split class declaration and definition

2014-07-31 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 31 July 2014 at 11:34:38 UTC, Kozzi11 wrote: Is possible to somehow split class declaration and definition. I mean something like this: class C { void hello(); // just prototype } class C { void hello() { //actual code } } or something like this void

Re: Get the default hash function.

2014-07-31 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 31 July 2014 at 12:05:53 UTC, francesco cattoglio wrote: Really simple question: how do I get the compiler-generated hash function for a given type? For example: Struct S { int i; } can be used in an associative array. That means the compiler generates a toHash function. Is

Re: extern (c++) std::function?

2014-08-15 Thread FreeSlave via Digitalmars-d-learn
On Friday, 15 August 2014 at 03:10:43 UTC, Etienne Cimon wrote: I'm looking into making a binding for the C++ API called Botan, and the constructors in it take a std::function. I'm wondering if there's a D equivalent for this binding to work out, or if I have to make a C++ wrapper as well?

Re: Crash writing and reading back class instance address to void*

2014-08-18 Thread FreeSlave via Digitalmars-d-learn
On Monday, 18 August 2014 at 10:07:30 UTC, Remi Thebault wrote: Hi Starting to use GtkD TreeModel, I write an instance of an abstract class to TreeIter.userData. When reading back the void pointer and casting to my abstract class leads to crash when instance is used (Task is the abstract

Re: struct or class

2014-08-24 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 24 August 2014 at 11:56:44 UTC, nikki wrote: I come from languages that don't offer structs, I have this json load function that has to keep some data and intuitively I've written a struct, I've read about the differences, heap vs stack, value vs reference, but know I think i am

Re: Loading Symbols from Loaded Libraries

2014-09-01 Thread FreeSlave via Digitalmars-d-learn
core.demangle.mangle to get mangled names of D functions. I also made some similar wrapper in my project https://bitbucket.org/FreeSlave/dido But it was not updated for a long time and now it's outdated (code uses dlopen and LoadLibrary which is wrong and should be changed to Runtime.loadLibrary. Same

Re: Linking C++ standard library works with GDC... but not DMD. (Linux)

2015-04-16 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 16 April 2015 at 08:51:15 UTC, TheGag96 wrote: Hi, I've got this project that requires me to link into a C++ backend. It works just fine when using GDC: gdc *.d [client libraries] However, this command using DMD does not work: dmd -L-lstdc++ *.d [client libraries] I still get

Re: stdout redirect

2015-04-12 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 12 April 2015 at 04:39:06 UTC, Philip Stuckey wrote: why not: import std.stdio; stdout = File(args[4], w+); stderr = File(args[4], w+); It just replaces the object, not redirects output. E.g. if you use printf somewhere it will use stdout, not file.

Re: Binary search in structs

2015-04-06 Thread FreeSlave via Digitalmars-d-learn
I think I found solution using opBinaryRight import std.range; struct S { int i; string s; int opCmp(int i) { return this.i - i; } int opCmp(ref const S s) { return this.i - s.i; } int opBinaryRight(string op)(int i) if (op == ) { return i

Binary search in structs

2015-04-05 Thread FreeSlave via Digitalmars-d-learn
I have array of structs sorted by specific field. How can I perform binary search using this field as a key? Currently I ended up with this, but it gives error: struct S { int i; string s; } import std.range; void main(string [] args) { S[] structs = [{1,hello}, {2,world}, {3,

Re: Binary search in structs

2015-04-05 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 5 April 2015 at 23:15:04 UTC, w0rp wrote: On Sunday, 5 April 2015 at 23:06:27 UTC, FreeSlave wrote: I have array of structs sorted by specific field. How can I perform binary search using this field as a key? Currently I ended up with this, but it gives error: struct S { int i

Re: Calling a cpp function from d

2015-06-16 Thread FreeSlave via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: Hi, I encountered the following error: Error: function files.SHGetFolderPath (void* hwndOwner, int nFolder, void* hToken, uint dwFlags, char* pszPath) is not callable using argument types (typeof(null), int, typeof(null), int,

Re: Calling a cpp function from d

2015-06-16 Thread FreeSlave via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 13:31:47 UTC, FreeSlave wrote: Also you may want to take a look at my library [1] where I use SHGetSpecialFolderPath (I know, it's deprecated, but it still works, so why not. I don't really need to bother with access tokens here). Note that I load shell32

Re: linking external libs

2015-07-02 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 2 July 2015 at 12:47:52 UTC, Nicholas Wilson wrote: On Thursday, 2 July 2015 at 12:19:06 UTC, Steven Schveighoffer wrote: On 7/2/15 8:10 AM, Nicholas Wilson wrote: [...] Try dmd -v, it will tell you the link line. Then you can try it yourself to see how to get it to work. I

Re: What is a mutable method?

2015-05-22 Thread FreeSlave via Digitalmars-d-learn
On Friday, 22 May 2015 at 12:12:46 UTC, tcak wrote: I know there is mutable variables, but what is a mutable method? Error message says mutable method project.mariadb.connector.ver2p1.resultset.ResultSetColumn.info is not callable using a const object. The method that can change the state

Re: How to provide this arg or functor for algorithm?

2015-08-16 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 16 August 2015 at 12:30:54 UTC, cym13 wrote: On Sunday, 16 August 2015 at 11:53:42 UTC, FreeSlave wrote: [...] Ok, so as my lambda proposition obviously doesn't work, here is one way that does using a templated function. There may be a way to make it shorter, I don't know

How to provide this arg or functor for algorithm?

2015-08-16 Thread FreeSlave via Digitalmars-d-learn
Let's say I want to map some range using some context. The obvious way is to do: uint[3] arr = [1,2,3]; uint context = 2; auto r = arr[].map!(delegate(value) { return value * context; }); The problem is that this allocates delegate, so it can't be used in @nogc code. What I want to do might

Re: How to provide this arg or functor for algorithm?

2015-08-16 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 16 August 2015 at 16:23:05 UTC, FreeSlave wrote: On Sunday, 16 August 2015 at 15:29:10 UTC, Ali Çehreli wrote: On 08/16/2015 04:53 AM, FreeSlave wrote: The problem is that this allocates delegate, so it can't be used in @nogc code. Would constructing the delegate by setting its

Re: How to provide this arg or functor for algorithm?

2015-08-16 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 16 August 2015 at 15:29:10 UTC, Ali Çehreli wrote: On 08/16/2015 04:53 AM, FreeSlave wrote: The problem is that this allocates delegate, so it can't be used in @nogc code. Would constructing the delegate by setting its .funcptr and .ptr properties work in this case? You can have

Re: A couple questions about a simple project

2015-08-17 Thread FreeSlave via Digitalmars-d-learn
On Monday, 17 August 2015 at 15:05:56 UTC, Andre Polykanine wrote: Hi everyone, I'm new to D (I'm learning it by reading the great online book by Ali Çehreli - thank you very much for it, sir!), and, more than that, programming is my hobby, so please bear with me if I'm asking stupid

Re: Environment variable for application storage under OSX ?

2015-07-17 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote: I have the following code, working under Win and Linux: --- import std.process: environment; immutable string p; static this() { version(Win32) p = environment.get(APPDATA); version(linux) p = /home/ ~ environment.get(USER);

Re: Environment variable for application storage under OSX ?

2015-07-17 Thread FreeSlave via Digitalmars-d-learn
On Friday, 17 July 2015 at 07:33:43 UTC, Anonymous wrote: On Friday, 17 July 2015 at 07:14:24 UTC, FreeSlave wrote: On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote: I have the following code, working under Win and Linux: --- import std.process: environment; immutable string p

Re: Decrease number of front evaluations

2015-08-26 Thread FreeSlave via Digitalmars-d-learn
On Wednesday, 26 August 2015 at 08:30:04 UTC, Yazan D wrote: On Wed, 26 Aug 2015 08:27:05 +, FreeSlave wrote: Are there ways to fix this? Should I consider writing my own range type probably? Check http://dlang.org/phobos/std_algorithm_iteration.html#.cache I tried it. It can help

Decrease number of front evaluations

2015-08-26 Thread FreeSlave via Digitalmars-d-learn
Example: import std.stdio; import std.algorithm; import std.path; import std.file; import std.exception; import std.getopt; import std.array; import std.range; auto algo(string fileName, string[] dirs, string[] extensions) { return dirs.filter!(delegate(dir) { bool ok;

Re: Why ElementType!(char[3]) == dchar instead of char?

2015-09-02 Thread FreeSlave via Digitalmars-d-learn
On Wednesday, 2 September 2015 at 05:00:42 UTC, drug wrote: 02.09.2015 00:08, Jonathan M Davis via Digitalmars-d-learn пишет: On Tuesday, September 01, 2015 20:05:18 drug via Digitalmars-d-learn wrote: My case is I don't know what type user will be using, because I write a library. What's the

Using dub configurations with libraries

2015-09-07 Thread FreeSlave via Digitalmars-d-learn
Let's say I have two dub packages: A and B. A is a library. B is library or application (does not matter) and depends on A. A has several configurations in dub.json. How to build the B package that way it will use non-default configuration of A?

Re: Are there any Phobos functions to check file permissions on Windows and Posix?

2015-09-07 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 6 September 2015 at 23:05:29 UTC, Jonathan M Davis wrote: http://dlang.org/phobos/std_file.html#.getAttributes will get you all of the file attributes for a file, though you'll have to look at the Windows and POSIX documentation to know how to interpret that. - Jonathan M Davis

Re: Regression?

2015-09-08 Thread FreeSlave via Digitalmars-d-learn
On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe wrote: Fixed it by changing into: ``` import std.conv : text; string json = File("../languages.json","r").byLineCopy().joiner.text; auto ls = json.parseJSON(); ``` Why would you read file by line and then merge

assumeSorted can't access private function when compiling with -debug

2016-01-09 Thread FreeSlave via Digitalmars-d-learn
Here's code: private { import std.algorithm; import std.range; import std.typecons; alias Tuple!(int, string) Data; } private bool myCmp(Data a, Data b) { return a[0] < b[0]; } auto bar() { return [Data(1, "one"), Data(2, "two")].assumeSorted!myCmp; } void main() {

Re: Recommended coding convention for combining unix and windows code ?

2016-06-07 Thread FreeSlave via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 15:33:57 UTC, chmike wrote: Hello I'm writing some code that I want to be portable across Posix and Windows. What is the recommended code convention for such type of code ? 80% of the class implementation is the same for both OS. Should I write the following and

Re: Can D interface with Free Pascal?

2016-01-28 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 28 January 2016 at 04:26:26 UTC, Taylor Hillegeist wrote: Just curious... I had a thought that perhaps since Objective C was a replacement for Pascal on the mac. that they might have the same interface. but I'm not savvy enough with fpc to figure out how to try it. Not directly.

Re: Distribution of D apps

2016-01-21 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 21 January 2016 at 13:26:15 UTC, W.J. wrote: On Wednesday, 20 January 2016 at 16:01:11 UTC, Dibyendu Majumdar wrote: Hi, I am trying to understand the options for distributing a D app to users. My assumption is that only the shared libraries and binaries need to be distributed,

Is it legal to use std.windows modules?

2016-04-08 Thread FreeSlave via Digitalmars-d-learn
std.windows.syserror and others have documentation comments, but they are not listed in online documentation on dlang.org. Is it ok to use functions and classes from this modules in D applications?

Re: "inline" conversion of array to immutable

2016-04-22 Thread FreeSlave via Digitalmars-d-learn
On Friday, 22 April 2016 at 09:25:32 UTC, Jeff Thompson wrote: Hello. The following code compiles OK where func creates a mutable array and main assigns it to an immutable variable: [...] Probably this is what you look for http://dlang.org/phobos/std_exception.html#.assumeUnique

Re: "inline" conversion of array to immutable

2016-04-22 Thread FreeSlave via Digitalmars-d-learn
On Friday, 22 April 2016 at 11:07:47 UTC, Jeff Thompson wrote: On Friday, 22 April 2016 at 09:40:14 UTC, FreeSlave wrote: On Friday, 22 April 2016 at 09:25:32 UTC, Jeff Thompson wrote: Hello. The following code compiles OK where func creates a mutable array and main assigns it to an immutable

Linking to library dependent on Objective-C functions

2016-04-30 Thread FreeSlave via Digitalmars-d-learn
I have two files. The one has Objective-C functions and interfaces declarations written in D. Another file is main app and it imports the first and uses its functions. Imported file: http://codepad.org/jqdBb6sh Main file: http://codepad.org/0gKBqKxi When I compile them in one command it run

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread FreeSlave via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 20:03:14 UTC, pineapple wrote: I would've expected this to work, but instead I get a compile error. Is my syntax wrong? Is this just not a case that map can handle, and I should be doing something else? import std.algorithm : map; import std.conv : to;

Re: Get program stats at run time

2016-07-01 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 30 June 2016 at 21:56:57 UTC, Special opOps wrote: How can I get the program stats at run time such as minimum and maximum amount of memory and cpu used, cpu architecture, os, etc? OS is compile-time constant. http://dlang.org/phobos/std_system.html#.os Or do you look for

  1   2   >