Re: dlang.org/Learn "hello_world".sort.chain ...

2023-12-26 Thread tony via Digitalmars-d-learn
On Tuesday, 26 December 2023 at 11:19:29 UTC, Sergey wrote: Use typeid, instead of typeof Thanks! Got quite a type but I will worry about that later: std.range.SortedRange!(Result, "a < b").SortedRange

TDPL book and __traits(compiles...) snippet

2021-07-10 Thread Tony via Digitalmars-d-learn
In section 6.2 of The D Programming Language it talks about how the compiler will try and tell if you are going to use a null reference. It gives this code snippet below to demonstrate that. But with DMD v2.096.1-dirty I am getting that the compiler thinks the code is OK. With a "!" the assert

Re: Error: Outside Unicode code space

2021-07-09 Thread Tony via Digitalmars-d-learn
On Friday, 9 July 2021 at 03:32:31 UTC, Adam D Ruppe wrote: On Friday, 9 July 2021 at 03:09:52 UTC, Tony wrote: The editor I am using (Code::Blocks) displays the characters just fine. So it seems that the error message should be "Error: Outside the ASCII code space". D supports stuff outside

Error: Outside Unicode code space

2021-07-08 Thread Tony via Digitalmars-d-learn
I copied some text from a web page into a comment and I get the error "Error: Outside Unicode code space". This appears to be an incorrect error message. It is upset about double quotes that lean forward or backwards, and apostrophes that lean backwards. And dashes that aren't the keyboard

Re: ChromeOS and DLang

2021-05-29 Thread Tony via Digitalmars-d-learn
On Thursday, 27 May 2021 at 19:39:15 UTC, Ozan Sueel wrote: Hi I think about writing apps vor ChromeOS, but before running in a death end, I ask by myself, is D a good choice for this approach? Any experience with this new upcoming operating system? New and upcoming? ChromeOS was first

Re: ugly and/or useless features in the language.

2021-05-23 Thread Tony via Digitalmars-d-learn
On Saturday, 15 May 2021 at 21:15:01 UTC, Ola Fosheim Grostad wrote: On Saturday, 15 May 2021 at 14:31:08 UTC, Alain De Vos wrote: In general it is better to have fewer features and instead improve metaprogramming so that missing features can be done in a library. Why is

Re: DConf talk : Exceptions will disappear in the future?

2021-01-08 Thread Tony via Digitalmars-d-learn
On Tuesday, 5 January 2021 at 18:42:42 UTC, Marvin wrote: On Monday, 4 January 2021 at 15:39:50 UTC, ludo456 wrote: Listening to the first visioconf of the Dconf 2020, titled Destroy All Memory Corruption, (https://www.youtube.com/watch?v=XQHAIglE9CU) Walter talks about not using exceptions

Re: Pro programmer

2019-08-25 Thread Tony via Digitalmars-d-learn
On Sunday, 25 August 2019 at 21:30:10 UTC, GreatSam4sure wrote: I am wondering as to what is the starting point of being a pro programmer. If I want to be a pro programmer what language must I start with? Most pro programmer I have heard of are all C and C++ Guru. Most of the best guys on

Re: Help me decide D or C

2019-08-02 Thread Tony via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 22:30:52 UTC, Alexandre wrote: My goals: 1) Improve as a programmer 2) Have fun doing programs That's it basically. I am planning to study all "free" time I have. I am doing basically this since last year. Are you only considering D and C or just mentioning

Re: Singleton in Action?

2019-02-02 Thread Tony via Digitalmars-d-learn
On Saturday, 2 February 2019 at 16:56:45 UTC, Ron Tarrant wrote: So, my big question is, do I instantiate like this: DSingleton singleton = new DSingleton; Or like this: DSingleton singleton = singleton.get(); And subsequent calls would be...? The same? Using get() only? This seems to be

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-12-02 Thread Tony via Digitalmars-d-learn
On Saturday, 1 December 2018 at 19:02:54 UTC, H. S. Teoh wrote: But that's precisely the problem. It's not always possible to tell whether a variable has been initialized. E.g.: To me, the possibility of a "false positive" doesn't preclude the use of a warning unless that possibility is

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-12-01 Thread Tony via Digitalmars-d-learn
On Saturday, 1 December 2018 at 11:16:49 UTC, Dukc wrote: This is great when it works, but the problem is that it would be gargantuan effort -and compile time sink- to make it work perfectly. When it's just about if-else if chains, switches or boolean logic as in the example, the analysis

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-30 Thread Tony via Digitalmars-d-learn
isocpp.org just had a link to a blog post where someone makes a case for uninitialized variables in C++ being an advantage in that you can potentially get a warning regarding use of an uninitialized variable that points out an error in your code.

Re: D is supposed to compile fast.

2018-11-25 Thread Tony via Digitalmars-d-learn
On Sunday, 25 November 2018 at 22:00:21 UTC, Chris Katko wrote: On Saturday, 24 November 2018 at 20:44:57 UTC, welkam wrote: On Friday, 23 November 2018 at 08:57:57 UTC, Chris Katko wrote: D is supposed to compile fast. You didnt read the fine print. It compiles simple code fast. Also

D Language 2.1

2018-11-25 Thread Tony via Digitalmars-d-learn
From std.compiler.D_major and std.compiler.D_minor I see that my D language version is at 2.0 . But the version of gdc front-end I am using (via Debian default gdc package as of a few months ago) from std.compiler.version_major and std.compiler.version_minor is at 2.68 . That is a lot of bug

version(StdDoc)

2018-11-23 Thread Tony via Digitalmars-d-learn
In std.compiler there is this code: /// Which vendor produced this compiler. version(StdDdoc) Vendor vendor; else version(DigitalMars) Vendor vendor = Vendor.digitalMars; else version(GNU) Vendor vendor = Vendor.gnu; else version(LDC) Vendor vendor =

Re: Who can stop it ? Help me,thank you.

2018-10-17 Thread Tony via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 14:06:49 UTC, FrankLike wrote: Where can get the new dmd or ldc2 that's no 'Trojan horse virus' ? https://dlang.org/download.html

Re: Why is it hard to make Qt bindings?

2018-07-05 Thread Tony via Digitalmars-d-learn
On Thursday, 5 July 2018 at 12:52:49 UTC, Steven Schveighoffer wrote: On 7/5/18 4:42 AM, drug wrote: There were several attempts to make Qt binding for dlang, but either they has failed or has been stalled. It would be nice to collect that experience. Considering 2.081 supports C++ special

Re: Passing directory as compiler argument not finding file

2018-04-13 Thread Tony via Digitalmars-d-learn
On Friday, 13 April 2018 at 12:46:32 UTC, Cym13 wrote: On Friday, 13 April 2018 at 01:27:06 UTC, Tony wrote: I think that the typical model (at least in other languages) is to only compile one D source file at a time. Compile the b.d file with the -c option to create an object file. Then put

Re: Passing directory as compiler argument not finding file

2018-04-12 Thread Tony via Digitalmars-d-learn
On Thursday, 12 April 2018 at 07:48:28 UTC, Jamie wrote: Really, it's more like: A/ a.d module A.a; import std.stdio; import B.b; void main() { writeln(f(4)); } B/ b.d module B.b; size_t f(size_t input) { return input * 2; } And in A/

Re: Passing directory as compiler argument not finding file

2018-04-12 Thread Tony via Digitalmars-d-learn
On Thursday, 12 April 2018 at 05:39:21 UTC, Jamie wrote: Am I using the -I compiler option incorrectly? I believe so. I think it is for finding import files, not the files you are compiling. - -I=directory Look for imports also

Re: Packages and module import

2018-03-19 Thread Tony via Digitalmars-d-learn
On Monday, 19 March 2018 at 17:29:10 UTC, Russel Winder wrote: I had assumed that a directory of modules was a package. So for example: [...] On Monday, 19 March 2018 at 17:29:10 UTC, Russel Winder wrote: To my amateur eyes, first command-line build looks like a linking of object files

Re: how to make private class member private

2018-03-18 Thread Tony via Digitalmars-d-learn
On Sunday, 18 March 2018 at 18:04:13 UTC, Tony wrote: On Tuesday, 13 March 2018 at 06:03:11 UTC, Mike Parker wrote: D is not C++, C#, or Java. C++ uses friend to get around the issue. Java has no solution. I don't know about C#. Java has four protection levels. If you don't explicitly

Re: how to make private class member private

2018-03-18 Thread Tony via Digitalmars-d-learn
On Sunday, 18 March 2018 at 18:32:42 UTC, Jonathan M Davis wrote: They're similar, but there are differences. For instance, you can do package(a) in D in order to do something like put the stuff in a.b.c in package a rather than a.b. Is there a known situation where it makes sense to put

Re: how to make private class member private

2018-03-18 Thread Tony via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 06:03:11 UTC, Mike Parker wrote: D is not C++, C#, or Java. C++ uses friend to get around the issue. Java has no solution. I don't know about C#. Java has four protection levels. If you don't explicitly specify [private, protected, public] the protection

Re: How to simplify nested ifs

2018-03-16 Thread Tony via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 12:23:06 UTC, Ozan Süel wrote: if (source?pool?repository?directory?users) // do something That type of chain is sometimes referred to as a "train wreck" (see Law of Demeter). If this is a common lookup it could be: if (source && source.GotSomeUsers() )

Re: Do forum posts use any markup language?

2018-03-10 Thread Tony via Digitalmars-d-learn
On Saturday, 10 March 2018 at 18:02:48 UTC, Bogdan wrote: I'd like to distinguish between regular text and code, maybe have quotes, etc. A poster has come up with a standard way to delineate code and also show if multiple files are involved (along with an "extraction to files" program):

Re: std.traits.isBoolean

2018-02-19 Thread Tony via Digitalmars-d-learn
On Monday, 19 February 2018 at 17:22:04 UTC, Nathan S. wrote: On Monday, 19 February 2018 at 15:12:15 UTC, Tony wrote: But, assuming there is a use case for it, what if you want to restrict to a type that is either boolean, or a struct/class that can substitute for boolean - how do you do that

Re: std.traits.isBoolean

2018-02-19 Thread Tony via Digitalmars-d-learn
On Monday, 19 February 2018 at 13:47:15 UTC, Basile B. wrote: Indeed but Phobos maintainers don't want the ...TypeOf family to be documented. (https://github.com/dlang/phobos/pull/5747) Ok, thanks. But, assuming there is a use case for it, what if you want to restrict to a type that is

Re: std.traits.isBoolean

2018-02-19 Thread Tony via Digitalmars-d-learn
On Sunday, 18 February 2018 at 15:12:50 UTC, Mike Parker wrote: Generally, no. But with alias this, it can be: = import std.traits : BooleanTypeOf; import std.stdio : writeln; struct NoBool { int x; } struct AliasThisBool { bool b; alias b this; } void main() { static

std.traits.isBoolean

2018-02-18 Thread Tony via Digitalmars-d-learn
At https://dlang.org/library/std/traits/is_boolean.html it has: enum isBoolean(T) = is(BooleanTypeOf!T) && !isAggregateType!T; per: https://dlang.org/library/std/traits/is_aggregate_type.html isAggregateType is true for [struct, union, class, interface]. So BooleanTypeOf!T is true for

Re: std.zip size limit of 2 GB?

2018-02-15 Thread Tony via Digitalmars-d-learn
On Thursday, 15 February 2018 at 18:49:55 UTC, Steven Schveighoffer wrote: I think it's inherent in the zlib API. I haven't used all of the library, but the portion I did use (using zstream) uses uint for buffer sizes. Wouldn't using a uint for buffer size give a size limit of greater

Wiki spam

2018-02-02 Thread Tony via Digitalmars-d-learn
Don't know if there is a better place to report this, but the wiki attracted a spammer: https://wiki.dlang.org/The_Search_Of_Charter_Yacht_Designer https://wiki.dlang.org/User:MichelMeudell

Re: String Type Usage. String vs DString vs WString

2018-01-14 Thread Tony via Digitalmars-d-learn
On Monday, 15 January 2018 at 02:09:25 UTC, rikki cattermole wrote: Unicode has three main variants, UTF-8, UTF-16 and UTF-32. The size of a code point is 1, 2 or 4 bytes. I think to be technically correct, 1 (UTF-8), 2 (UTF-16) or 4 (UTF-32) bytes are referred to as "code units" and the

Re: Rvalue references

2018-01-13 Thread Tony via Digitalmars-d-learn
On Sunday, 14 January 2018 at 00:55:27 UTC, Jonathan M Davis wrote: [...] It the simplest case, it means that the compiler does a bitwise copy rather than a deep copy, but in other cases, it means that the compiler is able to use the object in-place rather than creating a deep copy that

Re: Rvalue references

2018-01-11 Thread Tony via Digitalmars-d-learn
On Monday, 8 January 2018 at 23:31:27 UTC, Jonathan M Davis wrote: auto foo(T)(auto ref T t) { return t; } foo(42); will result in foo being instantiated as int foo(int t) { return t; } whereas int i; foo(i); will result in foo being instantiated as int foo(ref int t) {

DUB and lib curl (-lcurl)

2018-01-08 Thread Tony via Digitalmars-d-learn
I am on Ubuntu 16.04. I was looking at Getting Started with DUB: http://code.dlang.org/getting_started I did the "dub init myproject" and it worked fine. Then I added dependency: ' dependency "dub" version="~>1.3.0" ' as shown in the next step. This got an error:

Re: Error trying to build dlang.org

2018-01-03 Thread Tony via Digitalmars-d-learn
On Thursday, 4 January 2018 at 02:20:32 UTC, Seb wrote: On Thursday, 4 January 2018 at 01:50:47 UTC, Tony wrote: Following the instructions here on Ubuntu 16.04: https://github.com/dlang/dlang.org/blob/master/CONTRIBUTING.md I did the command make -f posix.mak html but it failed to

Error trying to build dlang.org

2018-01-03 Thread Tony via Digitalmars-d-learn
Following the instructions here on Ubuntu 16.04: https://github.com/dlang/dlang.org/blob/master/CONTRIBUTING.md I did the command make -f posix.mak html but it failed to successfully complete: --- make[1]: Leaving directory

Re: How to use the -I command line switch?

2018-01-03 Thread Tony via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 12:21:28 UTC, tipdbmp wrote: // C:\libs\my_module.d module my_module; void foo() {} // main.d module main; import my_module; void main() { foo(); } Running dmd with: dmd -IC:\libs main.d my_module.d I get: Error: module my_module is in file

Re: How to use the -I command line switch?

2018-01-03 Thread Tony via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 18:35:21 UTC, Ali Çehreli wrote: On 01/03/2018 09:10 AM, tipdbmp wrote: dmd main.d C:\libs\my_module.d That does not use the -I switch. It compiles if I specify the full path to my_module.d:     dmd -IC:\libs main.d C:\libs\my_module.d I don't understand the

Re: Slices and Dynamic Arrays

2017-12-31 Thread Tony via Digitalmars-d-learn
On Monday, 1 January 2018 at 02:10:14 UTC, Jonathan M Davis wrote: The DLang Tour should probably be fixed to use the term dynamic array though. Or embrace both terms but take care that it is clear that they are synonyms and one may be preferred depending on context. As a beginner, I had

Re: How do you safely deal with range.front?

2017-12-31 Thread Tony via Digitalmars-d-learn
On Sunday, 31 December 2017 at 13:14:10 UTC, aliak wrote: On Sunday, 31 December 2017 at 01:03:17 UTC, Tony wrote: For me, front() should throw a pre-defined exception when called on an empty range in order to eliminate undefined behavior. It does take some time to make a check, but D does

Re: Slices and Dynamic Arrays

2017-12-31 Thread Tony via Digitalmars-d-learn
On Sunday, 31 December 2017 at 14:24:40 UTC, Jonathan M Davis wrote: The D Slices article does an excellent job of explaining all of this. It's just that it calls the GC-allocated memory buffer the dynamic array instead of calling T[] the dynamic array like the language and spec do.

Re: Slices and Dynamic Arrays

2017-12-30 Thread Tony via Digitalmars-d-learn
On Sunday, 31 December 2017 at 04:20:28 UTC, codephantom wrote: On Sunday, 31 December 2017 at 03:57:17 UTC, Tony wrote: On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley wrote: double[] D = [3.14159]; Can you guess what D is? :D It took me a while but I finally came up with "a

Re: Slices and Dynamic Arrays

2017-12-30 Thread Tony via Digitalmars-d-learn
On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley wrote: double[] D = [3.14159]; Can you guess what D is? :D It took me a while but I finally came up with "a slice of pi"

Re: Slices and Dynamic Arrays

2017-12-30 Thread Tony via Digitalmars-d-learn
On Friday, 29 December 2017 at 23:13:20 UTC, Jonathan M Davis wrote: The term "slice" is a bit overused in D, meaning a variety of things. It doesn't help that some folks dislike the official terminology. In general, a slice is a contiguous group of elements. A slice of memory would be a

Re: How do you safely deal with range.front?

2017-12-30 Thread Tony via Digitalmars-d-learn
For me, front() should throw a pre-defined exception when called on an empty range in order to eliminate undefined behavior. It does take some time to make a check, but D does array bounds checking by default. Ideally the front() check could be turned off somehow ("-boundschecks=off") by the

Slices and Dynamic Arrays

2017-12-29 Thread Tony via Digitalmars-d-learn
In DLang Tour:Arrays https://tour.dlang.org/tour/en/basics/arrays there is: --- int size = 8; // run-time variable int[] arr = new int[size]; The type of arr is int[], which is a slice. --- In "D Slices"

DLang Tour : Functions as arguments

2017-12-27 Thread Tony via Digitalmars-d-learn
On this page: https://tour.dlang.org/tour/en/basics/delegates there is: void doSomething(int function(int, int) doer) { // call passed function doer(5,5); } doSomething(add); // use global function `add` here //

Ddoc - No Documentation

2017-12-02 Thread Tony via Digitalmars-d-learn
Wondering what the rationale is for this: https://dlang.org/spec/ddoc.html#no_documentation No Documentation No documentation is generated for the following constructs, even if they have a documentation comment: Invariants Postblits Destructors Static constructors and static destructors

Re: std.range.interfaces : InputRange moveFront

2017-11-30 Thread Tony via Digitalmars-d-learn
On Thursday, 30 November 2017 at 09:50:37 UTC, Tony wrote: On Thursday, 30 November 2017 at 09:47:14 UTC, Tony wrote: Thanks for the reply. Probably just missing it, but in poking around dlang.org (Language Reference and Library Reference) I am having trouble finding out about the move(),

Re: std.range.interfaces : InputRange moveFront

2017-11-30 Thread Tony via Digitalmars-d-learn
On Thursday, 30 November 2017 at 09:47:14 UTC, Tony wrote: Thanks for the reply. Probably just missing it, but in poking around dlang.org (Language Reference and Library Reference) I am having trouble finding out about the move(), front() and moveFront() functions, as is used here on a

Re: std.range.interfaces : InputRange moveFront

2017-11-30 Thread Tony via Digitalmars-d-learn
On Thursday, 30 November 2017 at 06:36:12 UTC, Ali Çehreli wrote: move is an operation that transfers the state of the source to the destination. The front element becomes its .init value and its previous values is returned by moveFront(). The important bit is that, the element is *not*

std.range.interfaces : InputRange moveFront

2017-11-29 Thread Tony via Digitalmars-d-learn
What does the moveFront() method do in the InputRange interface? std.range.interfaces : InputRange.moveFront()

Re: User defined type and foreach

2017-11-17 Thread Tony via Digitalmars-d-learn
On Saturday, 18 November 2017 at 05:24:30 UTC, Tony wrote: Forgot to handle pre-mature foreach exit: import std.stdio : writeln; class RefRange { int foreach_index; int[] items; this(int[] src) { items = src; } bool empty() { if (foreach_index ==

Re: User defined type and foreach

2017-11-17 Thread Tony via Digitalmars-d-learn
On Friday, 17 November 2017 at 17:55:30 UTC, Jonathan M Davis wrote: When you have foreach(e; range) it gets lowered to something like for(auto r = range; !r.empty; r.popFront()) { auto e = r.front; } So, the range is copied when you use it in a foreach. In the case of a class, it's

Re: User defined type and foreach

2017-11-17 Thread Tony via Digitalmars-d-learn
On Friday, 17 November 2017 at 07:40:35 UTC, Mike Parker wrote: You might also find use in this article (poorly adapted from Chapter 6 of Learning D by the publisher, but still readable): https://www.packtpub.com/books/content/understanding-ranges makes a distinction about "range

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Friday, 17 November 2017 at 01:16:38 UTC, H. S. Teoh wrote: It should be .empty, .popFront, and .front, not .pop. Also, these methods are *range* primitives, and over time, we have come to a consensus that generally speaking, it's a bad idea to conflate containers with ranges over

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Thursday, 16 November 2017 at 18:34:54 UTC, Steven Schveighoffer wrote: On 11/16/17 8:10 AM, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront()

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Thursday, 16 November 2017 at 13:35:13 UTC, Tony wrote: On Thursday, 16 November 2017 at 13:10:11 UTC, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Thursday, 16 November 2017 at 13:10:11 UTC, ag0aep6g wrote: On 11/16/2017 09:03 AM, Tony wrote: However, when I use the class with foreach, the opindex gets called to create a dynamic array, rather than use the empty(),front(),popFront() routines. I would prefer it use the three methods,

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Thursday, 16 November 2017 at 12:56:18 UTC, Steven Schveighoffer wrote: On 11/16/17 3:03 AM, Tony wrote: I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow

Re: User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
On Thursday, 16 November 2017 at 08:26:25 UTC, Andrea Fontana wrote: On Thursday, 16 November 2017 at 08:03:48 UTC, Tony wrote: I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods,

User defined type and foreach

2017-11-16 Thread Tony via Digitalmars-d-learn
I made a stack data type and created an opIndex() so it could be turned into a dynamic array, and created empty() (unfortunate name), front() and popFront() methods, which I read allow it to be used with foreach. However, when I use the class with foreach, the opindex gets called to create a

Re: Missing return value error not present with template

2017-11-15 Thread Tony via Digitalmars-d-learn
On Wednesday, 15 November 2017 at 11:20:24 UTC, Biotronic wrote: Thanks Biotronic! I found this on the html documentation for templates: "The body of the TemplateDeclaration must be syntactically correct even if never instantiated. Semantic analysis is not done until instantiated", and that

Missing return value error not present with template

2017-11-15 Thread Tony via Digitalmars-d-learn
This code: class MyClass { public: int SomeMethod () { } } void main() { } gets a compile error: Error: function test_warnings.MyClass.SomeMethod has no return statement, but is expected to return a value of type int but if I make it a template class: class MyClass(T) { there

Re: string version of array

2017-11-14 Thread Tony via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 07:56:06 UTC, rikki cattermole wrote: On 14/11/2017 7:54 AM, Tony wrote: Is there an easy way to get the string representation of an array, as would be printed by writeln(), but captured in a string? struct Foo { int x; } void main() { Foo[]

string version of array

2017-11-13 Thread Tony via Digitalmars-d-learn
Is there an easy way to get the string representation of an array, as would be printed by writeln(), but captured in a string?

Re: core file

2017-11-13 Thread Tony via Digitalmars-d-learn
On Monday, 13 November 2017 at 07:38:14 UTC, Ali Çehreli wrote: It is. If you search for "where is core file ubuntu" you will hit the output of 'man core', as well as answers like the following, which explains that the file may be under /var/cache/abrt:

Re: core file

2017-11-13 Thread Tony via Digitalmars-d-learn
On Monday, 13 November 2017 at 07:38:14 UTC, Ali Çehreli wrote: On 11/12/2017 10:25 PM, Tony wrote: >>> "Segmentation fault (core dumped)" I've been assuming that if it says "dumped", the core is dumped. > I am on Ubuntu 16.04. Thanks, I didn't know that "producing a core file" > was

Re: core file

2017-11-12 Thread Tony via Digitalmars-d-learn
On Monday, 13 November 2017 at 05:37:12 UTC, codephantom wrote: On Monday, 13 November 2017 at 05:01:18 UTC, Tony wrote: I am getting the message from my program execution: "Segmentation fault (core dumped)" But I don't see a core file in the current directory or in my home directory. Is

core file

2017-11-12 Thread Tony via Digitalmars-d-learn
I am getting the message from my program execution: "Segmentation fault (core dumped)" But I don't see a core file in the current directory or in my home directory. Is there one somewhere? Would I be able to do anything meaningful with it if it exists?

Re: Conditional compilation of array of structs initializer

2017-11-09 Thread Tony via Digitalmars-d-learn
Thanks Mike!

Conditional compilation of array of structs initializer

2017-11-09 Thread Tony via Digitalmars-d-learn
Doing a port of some C code that has an #ifdef in the middle of an initialization for an array of structs. I am getting a compile error trying to get equivalent behavior with "static if" or "version". Is there a way to achieve this other than making two separate array initialization sections?

Re: Any book recommendation for writing a compiler?

2017-11-07 Thread Tony via Digitalmars-d-learn
Author Allen Holub has made his out-of-print book, Compiler Design in C, available as a free pdf download: http://holub.com/compiler/ And Torben Mogensen is doing the same with his more recent Basics of Compiler Design: http://www.diku.dk/~torbenm/Basics/

Cyclic dependency error

2017-11-07 Thread Tony via Digitalmars-d-learn
My program compiled, but when I ran it I got this error message: object.Error@src/rt/minfo.d(371): Cyclic dependency between module variable and main variable* -> misc -> main* -> variable* I take it that the -> represents a dependency from the module on that line, to the module on the line

fputs, stdout

2017-11-06 Thread Tony via Digitalmars-d-learn
There is a fputs/stdout in core.stdc.stdio. std.stdio "public imports" that: "public import core.stdc.stdio;" Wondering why: import core.stdc.stdio : fputs; import core.stdc.stdio : stdout; void main() { fputs( cast(const char *)"hello world\n",stdout); } compiles and runs, but if I

Re: Associative arrays with keys containing mutable indirections

2017-10-30 Thread Tony via Digitalmars-d-learn
I prefer the built-in associative array over using some template library. It has the clean look and ease-of-use that you get with a similar data structure in dynamic languages like Python. I consider it a top feature of D.

Re: Garbage Collector profiling and the dynamic array reserve() function

2017-10-17 Thread Tony via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 13:27:24 UTC, Steven Schveighoffer wrote: I don't know what "allocations" represents, but reserve actually calls gc_malloc, and the others do not (the space is available to expand into the block). There should be only one allocation IMO. -Steve So there

Garbage Collector profiling and the dynamic array reserve() function

2017-10-17 Thread Tony via Digitalmars-d-learn
Found this unanswered question on StackOverflow. This program: import std.stdio; void add(ref int[] data) { data ~= 1; data ~= 2; } void main() { int[] a; writeln("capacity:",a.capacity); auto cap = a.reserve(1000); // allocated may be more than requested assert(cap

Re: @property with 2 arguments

2017-10-01 Thread Tony via Digitalmars-d-learn
On Sunday, 1 October 2017 at 07:11:14 UTC, bitwise wrote: On Sunday, 1 October 2017 at 05:57:53 UTC, Tony wrote: "@property functions can only have zero, one or two parameters" I am looking for an example of an @property function defined with two parameters and the syntax for how it is

Re: @property with 2 arguments

2017-10-01 Thread Tony via Digitalmars-d-learn
On Sunday, 1 October 2017 at 06:34:56 UTC, Jonathan M Davis wrote: On Sunday, October 01, 2017 05:57:53 Tony via Digitalmars-d-learn wrote: "@property functions can only have zero, one or two parameters" I am looking for an example of an @property function defined with two

@property with 2 arguments

2017-10-01 Thread Tony via Digitalmars-d-learn
"@property functions can only have zero, one or two parameters" I am looking for an example of an @property function defined with two parameters and the syntax for how it is accessed without ().

Re: Creating a dynamic library

2017-09-30 Thread Tony via Digitalmars-d-learn
On Saturday, 30 September 2017 at 10:09:43 UTC, Mike Wey wrote: On 30-09-17 03:27, Tony wrote: One thing I picked up from SCons is creating dynamic object files with a .os extension and static object files with the standard .o extension. That way they can be compiled in the same directory in

Re: core.stdc.time

2017-09-30 Thread Tony via Digitalmars-d-learn
On Saturday, 30 September 2017 at 07:45:27 UTC, Jacob Carlborg wrote: On 2017-09-30 08:56, Tony wrote: The documentation says: -- This module contains bindings to selected types and functions from the standard C header . Note that this is

core.stdc.time

2017-09-30 Thread Tony via Digitalmars-d-learn
The documentation says: -- This module contains bindings to selected types and functions from the standard C header . Note that this is not automatically generated, and may omit some types/functions from the original C header.

Re: Creating a dynamic library

2017-09-29 Thread Tony via Digitalmars-d-learn
On Saturday, 30 September 2017 at 01:02:08 UTC, Elronnd wrote: dmd bla.d bla2.d -shared -fPIC -oflibbla.so Thanks. I don't normally compile right into a .so, but I think this is OK: dmd my_file.o my_other_file.o -shared -of=libutest.so One thing I picked up from SCons is creating

Creating a dynamic library

2017-09-29 Thread Tony via Digitalmars-d-learn
I would like to know that command line (I am on Linux) I would use to compile a D file and create an object file that is suitable for a Linux dynamic library (.so). I believe it is probably dmd -c -fPIC my_file.d Also, what is the command line to create a dynamic library from one or more

Re: Coverage (-cov)

2017-09-23 Thread Tony via Digitalmars-d-learn
On Sunday, 24 September 2017 at 05:48:32 UTC, Tony wrote: I am compiling a module (utils) with one function in it with the -cov compiler option on Ubuntu 14.04 with DMD v2.073.2. I then compile a "main module" with -cov that imports the "utils module" and calls the one function. The *.lst

Coverage (-cov)

2017-09-23 Thread Tony via Digitalmars-d-learn
I am compiling a module (utils) with one function in it with the -cov compiler option on Ubuntu 14.04 with DMD v2.073.2. I then compile a "main module" with -cov that imports the "utils module" and calls the one function. The *.lst output file shows lines that executed in the "main module". I

How to set connect timeout on a blocking socket?

2017-09-11 Thread tony via Digitalmars-d-learn
Help me! How to set connect timeout on a blocking socket?

Re: Trying to compile weather program

2015-08-24 Thread Tony via Digitalmars-d-learn
I happened to notice that among my libcurl*s libcurl-gnutls.so.3 libcurl-gnutls.so.4 libcurl-gnutls.so.4.3.0 libcurl.so.3 libcurl.so.4 libcurl.so.4.3.0 none were just libcurl.so. So I made a link for libcurl.so to the latest version and now I am getting the same link errors I got after

Re: Trying to compile weather program

2015-08-24 Thread Tony via Digitalmars-d-learn
On Monday, 24 August 2015 at 06:28:34 UTC, Yazan D wrote: On Sun, 23 Aug 2015 16:00:16 +, Tony wrote: Thanks for the replies. It compiles OK with just. However, it isn't linking: /usr/bin/ld: cannot find -lcurl I do have some versions of libcurl on my system:

Re: Trying to compile weather program

2015-08-24 Thread Tony via Digitalmars-d-learn
On Sunday, 23 August 2015 at 16:20:04 UTC, Gerald Jansen wrote: On Sunday, 23 August 2015 at 16:00:19 UTC, Tony wrote: /usr/bin/ld: cannot find -lcurl Just the other day I had a similar problem (compiling vibenews, ld complained of missing -levent and -lssl), which I managed to solve simply

Re: Trying to compile weather program

2015-08-23 Thread Tony via Digitalmars-d-learn
On Sunday, 23 August 2015 at 16:00:19 UTC, Tony wrote: Thanks for the replies. It compiles OK with just. However, it isn't linking: /usr/bin/ld: cannot find -lcurl I do have some versions of libcurl on my system: /usr/lib/x86_64-linux-gnu/libcurl.so.3

Re: Trying to compile weather program

2015-08-23 Thread Tony via Digitalmars-d-learn
Thanks for the replies. It compiles OK with just. However, it isn't linking: /usr/bin/ld: cannot find -lcurl I do have some versions of libcurl on my system: /usr/lib/x86_64-linux-gnu/libcurl.so.3 /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0 /usr/lib/x86_64-linux-gnu/libcurl.so.4 I see there

Trying to compile weather program

2015-08-23 Thread Tony via Digitalmars-d-learn
I found this weather program on the main page (it seems to rotate what it here): // Get your local weather report pragma(lib, curl); import std.functional, std.json, std.net.curl, std.stdio, std.string; alias getJSON = pipe!(get, parseJSON); auto K2C = (float f) = f - 273.15; auto K2F =

main() return code.

2015-08-21 Thread Tony via Digitalmars-d-learn
Why is it acceptable to specify main as returning void (in addition to returning int)?

website update

2015-08-10 Thread Tony via Digitalmars-d-learn
It looks like this page: http://dlang.org/hash-map.html Should have the override keyword added the the member functions in Foo: class Foo { int a, b; size_t toHash() { return a + b; } bool opEquals(Object o) { Foo foo = cast(Foo) o; return foo a == foo.a b

  1   2   >