Re: Getting usages of template

2016-11-17 Thread lobo via Digitalmars-d-learn
On Thursday, 17 November 2016 at 09:40:45 UTC, Carlin St Pierre wrote: Is it possible to get the list of usages of a template during compile time? For example: class Foo { void bar(T)(T t) { } } void main() { Foo foo = new Foo; foo.bar(1); // int

Re: Why some function are class-less?

2016-11-17 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 17 November 2016 at 18:40:12 UTC, Suliman wrote: For example I need to write all logs to file. I see this function, that seem set some global file name. "setLogFileSets a log file for disk file logging." But would it name accessible from anywhere or it would be visible inl

Re: Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
On Thursday, 17 November 2016 at 18:02:02 UTC, Jesse Phillips wrote: On Thursday, 17 November 2016 at 17:54:23 UTC, Suliman wrote: Ok, but when the logger class may be more helpful that function usage? You'd use the logger class when you need to make customizations or have multiple logging sc

Re: Why is three safety levels need in D?

2016-11-17 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:18:27 UTC, Nordlöw wrote: Why does D need both `@safe`, `@trusted` and `@system` when Rust seems to get by with only safe (default) and `unsafe`? https://dlang.org/spec/memory-safe-d.html http://dlang.org/safed.html D makes it illegal for @safe code to call

Re: Why is three safety levels need in D?

2016-11-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:18:27 UTC, Nordlöw wrote: Why does D need both `@safe`, `@trusted` and `@system` when Rust seems to get by with only safe (default) and `unsafe`? I'm pretty sure the Rust `unsafe` just does both D's `@system` AND `@trusted`. An unsafe function in Rust is l

Re: Why some function are class-less?

2016-11-17 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:54:23 UTC, Suliman wrote: Ok, but when the logger class may be more helpful that function usage? You'd use the logger class when you need to make customizations or have multiple logging schemes. I'd expect Vibe.d allows you to override the global logging

Re: Why some function are class-less?

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:54:23 UTC, Suliman wrote: On Thursday, 17 November 2016 at 17:45:31 UTC, Stefan Koch wrote: On Thursday, 17 November 2016 at 17:42:44 UTC, Suliman wrote: On Thursday, 17 November 2016 at 16:46:37 UTC, Steven Schveighoffer wrote: On 11/17/16 11:28 AM, Suliman

Re: Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:45:31 UTC, Stefan Koch wrote: On Thursday, 17 November 2016 at 17:42:44 UTC, Suliman wrote: On Thursday, 17 November 2016 at 16:46:37 UTC, Steven Schveighoffer wrote: On 11/17/16 11:28 AM, Suliman wrote: [...] D does not require classes to write functions.

Re: Why is three safety levels need in D?

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:47:21 UTC, Nordlöw wrote: On Thursday, 17 November 2016 at 17:33:33 UTC, Stefan Koch wrote: Memory is inherently unsafe. But it can be treated in a safe way. A language that does not allow you to express a middle ground will have a lot of unsafe code that cou

Re: Why is three safety levels need in D?

2016-11-17 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:33:33 UTC, Stefan Koch wrote: Memory is inherently unsafe. But it can be treated in a safe way. A language that does not allow you to express a middle ground will have a lot of unsafe code that could arguably be seen as safe. So in what way would, for insta

Re: Why some function are class-less?

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:42:44 UTC, Suliman wrote: On Thursday, 17 November 2016 at 16:46:37 UTC, Steven Schveighoffer wrote: On 11/17/16 11:28 AM, Suliman wrote: [...] D does not require classes to write functions. All a class member function is anyway is a function with an impli

Re: Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
On Thursday, 17 November 2016 at 16:46:37 UTC, Steven Schveighoffer wrote: On 11/17/16 11:28 AM, Suliman wrote: There is some functions that can be called without creation of class. For example: http://vibed.org/api/vibe.core.log/ As I understand I can create write log in two way. First creat

Re: Why is three safety levels need in D?

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:29:20 UTC, Nordlöw wrote: On Thursday, 17 November 2016 at 17:27:01 UTC, Stefan Koch wrote: It allows encapsulating unsafe operations in safely-callable wrappers. So is this a limitation in Rust? If so, could you give a more concrete D code example that can

Re: Why is three safety levels need in D?

2016-11-17 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:27:01 UTC, Stefan Koch wrote: It allows encapsulating unsafe operations in safely-callable wrappers. So is this a limitation in Rust? If so, could you give a more concrete D code example that cannot be implemented with only two safety levels?

Re: Why is three safety levels need in D?

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:18:27 UTC, Nordlöw wrote: Why does D need both `@safe`, `@trusted` and `@system` when Rust seems to get by with only safe (default) and `unsafe`? https://dlang.org/spec/memory-safe-d.html http://dlang.org/safed.html It allows encapsulating unsafe operations

Why is three safety levels need in D?

2016-11-17 Thread Nordlöw via Digitalmars-d-learn
Why does D need both `@safe`, `@trusted` and `@system` when Rust seems to get by with only safe (default) and `unsafe`? https://dlang.org/spec/memory-safe-d.html http://dlang.org/safed.html

LDC vs DMD Diagnostics

2016-11-17 Thread Nordlöw via Digitalmars-d-learn
Does LDC have more diagnostics than DMD, typically unused imports, variables, etc?

Re: Why some function are class-less?

2016-11-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/17/16 11:28 AM, Suliman wrote: There is some functions that can be called without creation of class. For example: http://vibed.org/api/vibe.core.log/ As I understand I can create write log in two way. First create instance of Logger, second simply call function. Why it's done so? Just as

Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
There is some functions that can be called without creation of class. For example: http://vibed.org/api/vibe.core.log/ As I understand I can create write log in two way. First create instance of Logger, second simply call function. Why it's done so? Just as shortcut? But is I create class it'

Re: Assistance with DUB

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 22:01:23 UTC, Alfred Newman wrote: Greetings, I need some help with dub libraries. [...] test.d assumes that sqlite.d is given on the same compile command-line. This is the case when sqlite-d is build as a stand-alone app. If you want to integrate it I advise

Re: Getting usages of template

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 09:40:45 UTC, Carlin St Pierre wrote: Is it possible to get the list of usages of a template during compile time? For example: class Foo { void bar(T)(T t) { } } void main() { Foo foo = new Foo; foo.bar(1); // int

Getting usages of template

2016-11-17 Thread Carlin St Pierre via Digitalmars-d-learn
Is it possible to get the list of usages of a template during compile time? For example: class Foo { void bar(T)(T t) { } } void main() { Foo foo = new Foo; foo.bar(1); // int foo.bar(2f); // float foo.bar("3"); // string } // pragma(ms

Re: How to create a UTF16 text file on Windows?

2016-11-17 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 16 November 2016 at 22:43:55 UTC, lafoldes wrote: Hi, I'd like to create a UTF16 text file on Windows 7, using std.stdio.File and std.stdio.File.write... functions (so no binary write, no Win32 functions). I was experimenting with variations of this code…: import std.stdio; in