dpq2 documentation broken

2021-12-10 Thread kdevel via Digitalmars-d-learn
On https://code.dlang.org/packages/dpq2 I clicked at https://dpq2.dpldocs.info/v1.0.23/ and got: ``` Downloading package info... Downloading source code for version v1.0.23 from https://github.com/denizzzka/dpq2/archive/v1.0.23.zip... Unzipping D files... Generating documentation... this may t

function(pointer) as template argument, explicit template instantiation

2021-12-30 Thread kdevel via Digitalmars-d-learn
```dptr.d class R { } void foo (R r) { } alias fn = void function (R); void lyr (fn F) (R r) { } immutable fn foo_ptr = &foo; // line 14 pragma (msg, typeof (foo_ptr)); auto ptr = lyr!(foo_ptr);// line 17 ``` dmd reports: ``` immutable(void function(R)) dptr.d(14): Error: expression `& f

Re: function(pointer) as template argument, explicit template instantiation

2021-12-31 Thread kdevel via Digitalmars-d-learn
On Friday, 31 December 2021 at 03:02:08 UTC, Tejas wrote: [...] Is it okay to use template parameter instead of **template value** parameter? ```d class R { } void foo (R r) { } void lyr (fp_type, R) (fp_type fp, R r) { } pragma (msg, typeof (&foo)); R r; void main(){ auto foo_ptr = &foo;

Re: function(pointer) as template argument, explicit template instantiation

2021-12-31 Thread kdevel via Digitalmars-d-learn
On Friday, 31 December 2021 at 09:01:10 UTC, data pulverizer wrote: On Friday, 31 December 2021 at 00:57:26 UTC, kdevel wrote: Pointers are runtime entities and are not suitable template parameters (compile time). The address of a function does not change at runtime. The question is: Can func

Re: function(pointer) as template argument, explicit template instantiation

2021-12-31 Thread kdevel via Digitalmars-d-learn
On Friday, 31 December 2021 at 12:36:46 UTC, H. S. Teoh wrote: ``` void lyr(alias Fn)(ref R r) { Fn(r); } ``` Thanks! That helped me reinvent the engine.

Module without object file?

2022-01-04 Thread kdevel via Digitalmars-d-learn
In a project I have this "controller" function: ``` void create_fso (O) (Request req) { : auto npathname = (extract name from req) : O.create (npathname); : } public import fsobjects; ``` which creates a file system object. The possible object types I collected in a separate mod

Re: Module without object file?

2022-01-06 Thread kdevel via Digitalmars-d-learn
On Thursday, 6 January 2022 at 02:37:41 UTC, frame wrote: On Tuesday, 4 January 2022 at 22:17:38 UTC, kdevel wrote: Is there any chance to rephrase fsobjects.d such that it becomes a "header only"/"compile only" file of which no object file must be presented to the linker? You didn't show ho

Re: Module without object file?

2022-01-06 Thread kdevel via Digitalmars-d-learn
On Thursday, 6 January 2022 at 02:47:17 UTC, Steven Schveighoffer wrote: Possibly. You see, you are importing another module. Since you are doing that, the module must participate in cycle detection at the beginning of running the program. IC. Had cyclic module dependencies twice within this p

Re: srand in D

2022-01-08 Thread kdevel via Digitalmars-d-learn
On Sunday, 31 October 2021 at 17:02:00 UTC, Ali Çehreli wrote: Just comment that line out. :) D's pseudo-random generators start randomized by default: [...] https://dlang.org/phobos/std_random.html Klicking at "Run" always delivers "mango": https://dlang.org/phobos/std_random.html#unifo

Re: Module without object file?

2022-01-08 Thread kdevel via Digitalmars-d-learn
On Friday, 7 January 2022 at 09:18:29 UTC, frame wrote: On Thursday, 6 January 2022 at 22:54:59 UTC, kdevel wrote: In my setup make decides which file to (re)compile. Just found that dmd has the option -makedeps which resembles gcc's -M but theres no -MM to excluded dependencies from system fi

Re: srand in D

2022-01-08 Thread kdevel via Digitalmars-d-learn
On Saturday, 8 January 2022 at 23:34:17 UTC, Ali Çehreli wrote: [...] Apparently, the programmer wanted uniformly distributed randomness that is reproducible. That's why they use a generator that is seeded with 42 there. It does produce random results but the first Fruit happens to be "mango"

Re: srand in D

2022-01-09 Thread kdevel via Digitalmars-d-learn
On Sunday, 9 January 2022 at 03:15:02 UTC, Ali Çehreli wrote: What would work in the code above is 'choice': char q = choice(allowed_chars); But that hits another fact of D: arrays of chars are strings, which cannot be RandomAccessRange because individual chars must be decoded to form dchar

Re: How to update Associative Array?

2022-02-12 Thread kdevel via Digitalmars-d-learn
On Thursday, 10 February 2022 at 17:09:23 UTC, Ali Çehreli wrote: import std.traits : isAssociativeArray, isImplicitlyConvertible, KeyType, ValueType; void update(Target, From)(ref Target target, From from) if (isAssociativeArray!Target && isAssociativeArray!From && isImplicitlyConverti

Re: How to update Associative Array?

2022-02-13 Thread kdevel via Digitalmars-d-learn
On Sunday, 13 February 2022 at 01:27:45 UTC, Ali Çehreli wrote: [...] > If I remove the constraint (the if-stuff) I get > > v1.d(12): Error: cannot implicitly convert expression `kv.value()` > of type `byte` to `string` > v1.d(23): Error: template instance `v1.update!(string[int], > byte[

initializing struct containing user defined type

2022-02-18 Thread kdevel via Digitalmars-d-learn
Instead of using string I want to use A in the definition of B: struct A { string s; this (string s) { this.s = s; } } struct B { A a; A b; } Alas I have some difficulty initializing a B in the accustomed manner (b3): void main ()

Re: How to update Associative Array?

2022-02-18 Thread kdevel via Digitalmars-d-learn
On Monday, 14 February 2022 at 01:04:08 UTC, Ali Çehreli wrote: [...] Point taken but how deep should we understand library code, not all being Phobos. My pet peeve: import std.stdio; void main(string[] args) { writefln!"hello"(42); } /usr/include/dlang/dmd/std/stdio.d(4442): Error: no pr

Re: initializing struct containing user defined type

2022-02-18 Thread kdevel via Digitalmars-d-learn
On Friday, 18 February 2022 at 14:37:25 UTC, Ali Çehreli wrote: On 2/18/22 06:19, kdevel wrote: > // auto b3 = B ("A", "B"); // Error: cannot implicitly convert > // expression `"A"` of type `string` to `A` Yeah, D disallows some implicit conversions. Adding a constructor to B will m

template instance does not match template declaration

2022-02-25 Thread kdevel via Digitalmars-d-learn
``` $ dmd --version DMD64 D Compiler v2.098.1 [...] ``` ```main.d module main; // main.d import std.traits; import model; void main () { enum Q = Parameters!read; } ``` ```model.d module model; // model.d import std.file : read; // this line provokes the error int read (string filename) {

Re: template instance does not match template declaration

2022-02-25 Thread kdevel via Digitalmars-d-learn
```main.d module main; // main.d import std.traits; import model; void main () { enum Q = Parameters!read; } ``` Will not compile with selective import commented out. Hence main.d must read (alias instead of enum): ```main.d module main; // main.d import std.traits; import model; void ma

Re: template instance does not match template declaration

2022-02-25 Thread kdevel via Digitalmars-d-learn
On Friday, 25 February 2022 at 23:17:14 UTC, Paul Backus wrote: [...] Currently, selective imports are implemented using `alias`es under the hood, which means that the compiler sees your `model` module as having *two* overloads of `read`: ```d alias read = std.file.read; // from selective impo

dmd 2.099 regression: unittest -checkaction=context and import std.regex cause lots of undefined references

2022-03-17 Thread kdevel via Digitalmars-d-learn
zstack.d: ``` module zstack; import std.stdio: writeln; void bar (int [] i) { writeln ("i: ", i); } unittest { int [] arr; bar (arr); } ``` zrepo.d: ``` module parser; import std.regex; import zstack; ``` ``` $ dmd -g -i -unittest -checkaction=context -main -run zrepro 2>&1 | ddem

Re: Windows Msys terminal not flushing on newlines

2022-03-27 Thread kdevel via Digitalmars-d-learn
Don't know if this is OT here. On Sunday, 27 March 2022 at 18:09:30 UTC, Adam D Ruppe wrote: If the C library thinks it is talking to a pipe, it will switch to block buffering instead of line buffering. It must just think msys is a pipe (since it probably is under the hood). while compiling a

Re: fft and isPowerOf2?

2018-05-17 Thread kdevel via Digitalmars-d-learn
On Thursday, 17 May 2018 at 12:34:25 UTC, Andre Pany wrote: this applications throws an error in std.numeric (Line 2826). => assert(isPowerOf2(range.length)); Isn't it possible to give an arbitrary length of data to fft like in numpy? There is a mathematical background which is well explaine

Re: Mysql query result access by field name

2018-05-21 Thread kdevel via Digitalmars-d-learn
On Sunday, 20 May 2018 at 16:08:03 UTC, ipkwena wrote: How does one access the columns fields in a Mysql query results by the column name. [...] Data f; f.name = to!string(allrows[0][0]); f.surname = to!string(allrows[0][1]); f.title = to!string(allrows[0][2]); I am using the mysql-native p

Re: Mysql query result access by field name

2018-05-21 Thread kdevel via Digitalmars-d-learn
On Monday, 21 May 2018 at 14:17:23 UTC, Steven Schveighoffer wrote:    Data f;    allrows[0].toStruct (f); I haven't checked this. This only works if your struct has exactly the same layout as the fields. So if, for instance, your rows are selected "title", "name", "surname", but your da

Nullable!T with T of class type

2018-06-25 Thread kdevel via Digitalmars-d-learn
Just stumbled over the following design: class S {...} class R { : Nullable!S s; : } s was checked in code like R r; : if (r.s is null) throw new Exception ("some error message"); At runtime the following was caught: fatal error: caught Throwable

Re: Nullable!T with T of class type

2018-06-26 Thread kdevel via Digitalmars-d-learn
On Monday, 25 June 2018 at 22:58:41 UTC, Jonathan M Davis wrote: On Monday, June 25, 2018 19:40:30 kdevel via Digitalmars-d-learn wrote: R r; if (r.s is null) throw new Exception ("some error message"); [...] Why can't this programming error be detected at com

Re: Nullable!T with T of class type

2018-06-26 Thread kdevel via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 14:32:59 UTC, Nathan S. wrote: On Monday, 25 June 2018 at 19:40:30 UTC, kdevel wrote: Is it possible to "lower" the Nullable operations if T is a class type such that there is only one level of nullification? Yes: https://run.dlang.io/is/hPxbyf template Null

Re: Nullable!T with T of class type

2018-06-28 Thread kdevel via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 21:54:49 UTC, Jonathan M Davis wrote: [H]onestly, I don't understand why folks keep trying to put nullable types in Nullable in non-generic code. How do you signify that a struct member of class type is optional?

Re: Nullable!T with T of class type

2018-06-28 Thread kdevel via Digitalmars-d-learn
On Thursday, 28 June 2018 at 19:22:38 UTC, Jonathan M Davis wrote: Nullable makes sense in generic code, because the code isn't written specifically for them, but something like Nullable!MyClass in non-generic code is pointless IMHO, because a class reference is already nullable. It is alread

errnoEnforce: which imports?

2018-06-28 Thread kdevel via Digitalmars-d-learn
In https://dlang.org/phobos/std_exception.html#errnoEnforce this example is shown: --- auto f = errnoEnforce(fopen("data.txt")); auto line = readln(f); enforce(line.length); // expect a non-empty line --- I added import std.stdio; import std.exception; and get an error message which rem

Re: errnoEnforce: which imports?

2018-06-29 Thread kdevel via Digitalmars-d-learn
On Friday, 29 June 2018 at 02:28:04 UTC, Jonathan M Davis wrote: [...] really, that example needs to be completely redone. Shall I create a bug report?

Re: errnoEnforce: which imports?

2018-06-29 Thread kdevel via Digitalmars-d-learn
On Friday, 29 June 2018 at 09:22:03 UTC, Jonathan M Davis wrote: Shall I create a bug report? Yes. Aside from someone trying it out and complaining about it, it probably wouldn't be noticed or fixed, since it's one of the few tests that doesn't work as a ddoc-ed unit test. Issue 19041 - err

guard clause style static if

2018-07-07 Thread kdevel via Digitalmars-d-learn
It appears not to be possible to use static if in "guard clause style" as in void bar (T ...) (T args) { static if (args.length == 0) return; writeln (args [0]); return bar (args [1 .. $]); } Is this intended?

Re: guard clause style static if

2018-07-07 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 11:29:35 UTC, rikki cattermole wrote:   static if (args.length == 0) return; else {   writeln (args [0]);   return bar (args [1 .. $]); } That's not guard clause style [1][2]. [1] https://refactoring.com/catalog/replaceNestedConditio

Re: guard clause style static if

2018-07-07 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 11:56:40 UTC, rikki cattermole wrote: On 07/07/2018 11:44 PM, kdevel wrote: On Saturday, 7 July 2018 at 11:29:35 UTC, rikki cattermole wrote:    static if (args.length == 0)   return; else {    writeln (args [0]);    return bar (args [1 .. $]

Re: guard clause style static if

2018-07-07 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 12:46:08 UTC, rikki cattermole wrote: On 08/07/2018 12:40 AM, kdevel wrote: Interesting alternative That was not an alternative. That is what your code was doing. What my original code was supposed to do. But it did not compile. Error: array index [0] is outsi

Re: guard clause style static if

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 00:11:27 UTC, Steven Schveighoffer wrote: On 7/7/18 7:28 AM, kdevel wrote: It appears not to be possible to use static if in "guard clause style" as in    void bar (T ...) (T args)    {   static if (args.length == 0) return;   writeln (args [0

Re: guard clause style static if

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 13:03:32 UTC, rikki cattermole wrote: void func() { return; func2(); } Which is clearly an error. Hence why you need to add else block. There is no error in this generated code because func2 is unreachable. That there is a state/stage during compil

Re: guard clause style static if

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 13:12:59 UTC, Alex wrote: The site you cited for the guard clause above (c2.com) works at runtime. ? The intention is to shorten the paths inside a function, I think. Therefore, a static "guard clause" is a contradiction, if I understand it correctly. The term "

Re: guard clause style static if

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 11:56:40 UTC, rikki cattermole wrote: void bar (T ...) (T args) if (T.length == 0) { return; [...] } void bar (T ...) (T args) if (T.length > 0) { writeln (args [0]); return bar (args [1 .. $]); } This is a version without a se

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 20:10:54 UTC, Adam D. Ruppe wrote: On Tuesday, 10 July 2018 at 19:01:22 UTC, Per Nordlöw wrote: [...] Run the program in a debugger, or run `ulimit -c unlimited` to enable core dumps [...] Works for null ptr deref but how do I enforce core dumps in this code: du

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 21:09:23 UTC, Steven Schveighoffer wrote: [...] As far as the OS is concerned, a[2 .. $] is within the process memory limit. Of course, that's an out of bounds access, so the compiler or the bounds check *should* complain. It complains at runtime > ./dumpme2

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 22:31:54 UTC, Adam D. Ruppe wrote: Turn off rtTrapExceptions though the command line switch PR is STILL NOT MERGED https://github.com/dlang/druntime/pull/2035 extern (C) __gshared bool rt_trapExceptions; static this () { rt_trapExceptions = false

What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread kdevel via Digitalmars-d-learn
What does auto std.stdio.File.ByChunkImpl byChunk ( ulong chunkSize ); on https://dlang.org/library/std/stdio/file.by_chunk.html mean? Is that a (forward) declaration of a function named byChunk taking a single ulong argument name chunkSize. But what does that function return?

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread kdevel via Digitalmars-d-learn
On Friday, 3 August 2018 at 17:06:16 UTC, Adam D. Ruppe wrote: On Friday, 3 August 2018 at 16:58:26 UTC, kdevel wrote: What does auto std.stdio.File.ByChunkImpl byChunk ( ulong chunkSize ); on https://dlang.org/library/std/stdio/file.by_chunk.html mean? It looks like ddox trying to

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread kdevel via Digitalmars-d-learn
On Friday, 3 August 2018 at 17:27:07 UTC, Adam D. Ruppe wrote: But remember, this is documentation that just happens to look like code, so it is intended to be legible by people rather than the compiler. I could not find any elucidation of the meaning of auto when used as a return type o

reimplementing an interface in a derived class

2019-01-03 Thread kdevel via Digitalmars-d-learn
https://dlang.org/spec/interface.html #11 has this code example: ``` interface D { int foo(); } class A : D { int foo() { return 1; } } class B : A, D { override int foo() { return 2; } } ... B b = new B(); b.foo();// returns 2 D d = cast(D) b; d.foo();// r

Re: reimplementing an interface in a derived class

2019-01-04 Thread kdevel via Digitalmars-d-learn
On Friday, 4 January 2019 at 11:27:59 UTC, Alex wrote: On Friday, 4 January 2019 at 09:58:59 UTC, bauss wrote: [...] As for the OP, I think here the usefulness of ", D" should be visible: [...] class B : A, D { override int foo() { return 2; } } [...] D d = cast(D) b; asse

Re: reimplementing an interface in a derived class

2019-01-04 Thread kdevel via Digitalmars-d-learn
On Friday, 4 January 2019 at 20:21:56 UTC, Steven Schveighoffer wrote: missing in the source. But why is d a null reference in the first place? Because when you dynamically cast one object or interface to another object or interface, and that result is not possible (if you remove ",D" from th

D man pages

2019-01-05 Thread kdevel via Digitalmars-d-learn
For years I missed the man pages of the C++ standard library and now found out that some Linux distros provide them as extra package. The man pages are not generated by a default during a GCC bootstrap install but need an explicit make doc-install-man in the corresponding doc directory of libst

GCC 4.9.4 + GDC-patch: internal compiler error in libphobos/src/std/math.d:8040:47

2019-01-05 Thread kdevel via Digitalmars-d-learn
I applied the head commit ce249d880969111384d17f744687e427c843f1d4 Merge: 8a6b7a4 0e517e4 Author: Eugene Wissner Date: Tue Apr 10 15:37:32 2018 +0200 Merge pull request #647 from belka-ew/gdc-49up Merge branch gdc-5 into gdc-4.9 of branch gdc-4.9 on top of gcc-4.9.

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-17 Thread kdevel via Digitalmars-d-learn
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote: On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote: [...] auto window = Window(); window.title = "My Window"; window.width = 1000; window.create(); [...] Is there a better way that's not ugly? [...] //usage: au

API Documentation

2019-01-20 Thread kdevel via Digitalmars-d-learn
Online but not on a local installation I frequently land on pages under https://dlang.org/library/ (API Documentation). What is the reason for this duplicate docs? The API documentation looks much cleaner and better structured. https://dlang.org/library/std/range.html vs. https://dlang.org/pho

Re: Singleton in Action?

2019-02-05 Thread kdevel via Digitalmars-d-learn
On Monday, 4 February 2019 at 10:17:53 UTC, bauss wrote: On Saturday, 2 February 2019 at 16:56:45 UTC, Ron Tarrant wrote: [...] Here's the singleton code I've been playing with: [...] static bool instantiated_; // Thread global __gshared DSingleton instance_; [...

dirEntries within static foreach: memory.d(827): Error: fakePureErrno cannot be interpreted at compile time, because it has no available source code

2019-02-10 Thread kdevel via Digitalmars-d-learn
I am trying to get this code compiled: ```TemplateStore.d module TemplateStore; import std.path; import std.conv; import std.file; immutable string[string] template_map; static this () { static foreach (f; dirEntries (``, `*.html`, SpanMode.shallow)) { pragma (msg, `reading template

Re: dirEntries within static foreach: memory.d(827): Error: fakePureErrno cannot be interpreted at compile time, because it has no available source code

2019-02-10 Thread kdevel via Digitalmars-d-learn
On Monday, 11 February 2019 at 00:54:27 UTC, Seb wrote: On Monday, 11 February 2019 at 00:19:02 UTC, kdevel wrote: [...] You can't read or list files at compile-time. dmd can read files at compile time using the import function [1] What are you trying to do? Incorporate HTML template fi

Re: Casting int[] to ubyte[]: element wise cast or slice cast

2019-02-16 Thread kdevel via Digitalmars-d-learn
On Friday, 15 February 2019 at 18:11:11 UTC, Dennis wrote: Your should report our observation: https://issues.dlang.org ``` void main () { enum A = [0x10203040, 0x50607080]; // shall enum behave like immutable? auto B = [0x10203040, 0x50607080]; assert (A == B); auto p = cast (ubyt

latin9 characters in filesystem and command line; std.encoding [ISO-8859-15]

2019-03-17 Thread kdevel via Digitalmars-d-learn
This program: ```ls.d import std.stdio; import std.file; void main (string [] args) { auto entries = dirEntries (args[1], SpanMode.shallow, false); foreach (e; entries) writeln (e.name); } ``` lists the contents of a directory even if args[1] and the filesystem contain names encoded

Re: How to decode UTF-8 text?

2019-03-27 Thread kdevel via Digitalmars-d-learn
On Wednesday, 27 March 2019 at 13:39:07 UTC, Andrey wrote: I have got some text with UTF-8. For example this part: Παράλληλη αναζήτηση This looks like a UTF-8 sequence which has been UTF-8 encoded. How to decode it to get this result? Παράλληλη αναζήτηση Undo the second

§ 28.3 Pointers and the Garbage Collector

2019-04-07 Thread kdevel via Digitalmars-d-learn
In § 28.3 Pointers and the Garbage Collector [1] we read Do not add or subtract an offset to a pointer such that the result points outside of the bounds of the garbage collected object originally allocated. char* p = new char[10]; char* q = p + 6; // ok q = p + 11;

Re: § 28.3 Pointers and the Garbage Collector

2019-04-07 Thread kdevel via Digitalmars-d-learn
On Sunday, 7 April 2019 at 10:17:53 UTC, AltFunction1 wrote: On Sunday, 7 April 2019 at 10:05:26 UTC, kdevel wrote: In § 28.3 Pointers and the Garbage Collector [1] we read Do not add or subtract an offset to a pointer such that the result points outside of the bounds of the garbage coll

Re: Iterate/sort associative array by value?

2019-04-08 Thread kdevel via Digitalmars-d-learn
On Sunday, 7 April 2019 at 17:16:12 UTC, Seb wrote: --- ["a": 1].byPair.array.sort!((a, b) => a.value < a.value).release.each!writeln; --- What's the purpose of .release? The documentation in https://dlang.org/phobos/std_range.html#.SortedRange.release is rather monosyllabic.

Cyclic dependency between module A and B

2019-04-10 Thread kdevel via Digitalmars-d-learn
Recently (before refactoring) my application complained right after invocation: object.Error@src/rt/minfo.d(371): Cyclic dependency between module Filebrowser and App Filebrowser* -> App* -> Filebrowser* Is it possible to detect this dependency before the program is started? Per

Re: Packages / imports & references between modules

2019-04-28 Thread kdevel via Digitalmars-d-learn
On Sunday, 28 April 2019 at 14:24:08 UTC, Robert M. Münch wrote: On 2019-04-28 11:44:03 +, Mike Parker said: They're different symbols because they're in different modules. The module and package name is part of the symbol name. Ok, that's what I assumed too. Just import A.b in A.a.

dmd -unittest -main -run: undefined reference to `_D1c12__ModuleInfoZ'

2019-05-01 Thread kdevel via Digitalmars-d-learn
In the current working directory b/ I have package.d ``` module b; import c; void bar (string s) { mkdir (s); } ``` c/package.d ``` module c; package import std.file; ``` $ dmd -unittest -main package.d c/package.d produces the binary "package" as expected, but $ dmd -unittest -main

Re: dmd -unittest -main -run: undefined reference to `_D1c12__ModuleInfoZ'

2019-05-01 Thread kdevel via Digitalmars-d-learn
On Wednesday, 1 May 2019 at 22:35:12 UTC, ag0aep6g wrote: On 02.05.19 00:25, kdevel wrote: dmd -unittest -main -run package.d c/package.d That doesn't compile c/package.d. Everything after `-run package.d` is interpreted as an argument to the compiled program. Thanks for the information. W

Re: dmd -unittest -main -run: undefined reference to `_D1c12__ModuleInfoZ'

2019-05-01 Thread kdevel via Digitalmars-d-learn
On Wednesday, 1 May 2019 at 22:35:12 UTC, ag0aep6g wrote: [...] Or use -i so that DMD compiles the imported module automatically: dmd -unittest -main -i -run package.d Now I have: a/main.d a/b/package.d a/b/c/package.d b/package.d and c/package.d as before. a/main.d is ``` import b; v

Re: Framework design, initialization and framework usage

2019-05-12 Thread kdevel via Digitalmars-d-learn
On Wednesday, 8 May 2019 at 09:15:41 UTC, Ron Tarrant wrote: On Wednesday, 8 May 2019 at 06:30:56 UTC, Robert M. Münch wrote: Our focus is executable size (I'm an old school guy) and speed. What about correctness? [...] For some simple real-time grid example see: https://www.dropbox.com/s/

Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-17 Thread kdevel via Digitalmars-d-learn
On Thursday, 16 May 2019 at 20:31:23 UTC, Vladimir Panteleev wrote: On Thursday, 16 May 2019 at 20:17:37 UTC, Steven Schveighoffer [...] hnsecs is more confusing than nanoseconds. People know what a nanosecond is, a hecto-nano-second is not as familiar a term. Agreed, which is why Duration.

Re: Framework design, initialization and framework usage

2019-05-17 Thread kdevel via Digitalmars-d-learn
On Monday, 13 May 2019 at 09:25:05 UTC, ztop wrote: [...] The old site is archived in wayback https://web.archive.org/web/20180103191733/http://antigrain.com/ Thanks. That is the page I have been looking for: https://web.archive.org/web/20180306023416/http://www.antigrain.com/research/font_ra

Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-17 Thread kdevel via Digitalmars-d-learn
On Friday, 17 May 2019 at 20:30:56 UTC, Bastiaan Veelo wrote: On Friday, 17 May 2019 at 18:36:00 UTC, ag0aep6g wrote: I'd suggest "17 ms, and 553.1µs" for a better default (1 hns is 0.1 µs, right?). No weird "hnsecs", no false precision, still all the data that is there. I was going to propos

mixing (else) static if inadvertently with else if

2019-05-18 Thread kdevel via Digitalmars-d-learn
Today I stumbled over this error: elsestaticif.d ``` import std.stdio; void insert () () { // some code } void insert (T, Args ...) (T x, Args args) { static if (T.stringof == "int") {{ `int`.writeln; }} else if (T.stringof == "bool") {{ // ← "static" is missing here `bo

Re: Is using floating point type for money/currency a good idea?

2019-05-20 Thread kdevel via Digitalmars-d-learn
On Monday, 20 May 2019 at 11:47:25 UTC, Josh wrote: On Monday, 20 May 2019 at 11:10:32 UTC, Boqsc wrote: https://dlang.org/spec/float.html I'm frozen in learning basics of D lang since I want to create a simple game and I really would like a clean and simple code, however to me floating point

Re: Framework design, initialization and framework usage

2019-05-20 Thread kdevel via Digitalmars-d-learn
On Sunday, 19 May 2019 at 13:07:36 UTC, Robert M. Münch wrote: On 2019-05-12 17:33:16 +, kdevel said: [...] What about correctness? Correctness of what? Open a new document in MS Word or any other word processor and then press and hold the "L" key until the cursor hits the right margi

Re: Why GNU coreutils/dd is creating a dummy file more efficiently than D's For loop?

2019-05-23 Thread kdevel via Digitalmars-d-learn
On Thursday, 23 May 2019 at 09:44:15 UTC, Cym13 wrote: [...] Note in particular the blocksize argument. I set it to 1M but by default it's 512 bytes. If you use strace with the command above you'll see a series of write() calls, each writting 1M of null bytes to testfile. That's the main diff

The Nullity Of strings and Its Meaning

2017-07-08 Thread kdevel via Digitalmars-d-learn
Yesterday I noticed that std.uri.decodeComponent does not 'preserve' the nullity of its argument: 1 void main () 2 { 3import std.uri; 4string s = null; 5assert (s is null); 6assert (s.decodeComponent); 7 } The assertion in line 6 fails. This failure gave ris

Re: The Nullity Of strings and Its Meaning

2017-07-08 Thread kdevel via Digitalmars-d-learn
Just saw that my first example was wrong, it should read 1 void main () 2 { 3import std.uri; 4string a = ""; 5assert (a); 6auto s = a.decodeComponent; 7assert (s); 8 } The non-nullity was not preserved. Only the second assert fa

NNTP error: Disconnected from server (Connection closed)

2017-07-09 Thread kdevel via Digitalmars-d-learn
What's going on here?

Re: The Nullity Of strings and Its Meaning

2017-07-09 Thread kdevel via Digitalmars-d-learn
On Saturday, 8 July 2017 at 23:12:15 UTC, Jonathan M Davis wrote: On Saturday, July 8, 2017 5:16:51 PM MDT kdevel via Digitalmars-d-learn wrote: [...] IMHO, if you want to check for empty, then you should use the empty property or check length directly, since those are clear about your

Re: The Nullity Of strings and Its Meaning

2017-07-09 Thread kdevel via Digitalmars-d-learn
On Sunday, 9 July 2017 at 10:32:23 UTC, ag0aep6g wrote: On 07/09/2017 01:12 AM, kdevel wrote: On Saturday, 8 July 2017 at 18:39:47 UTC, ag0aep6g wrote: On 07/08/2017 07:16 PM, kdevel wrote: [...] Moreover everything I've written about strings is also valid for e.g. dynamic arrays of doubles

Re: The Nullity Of strings and Its Meaning

2017-07-09 Thread kdevel via Digitalmars-d-learn
On Sunday, 9 July 2017 at 13:51:44 UTC, kdevel wrote: But that second proposition what not the one chosen in the documentation. Shall read: "But that second predicate was not the one chosen in the documentation."

Re: The Nullity Of strings and Its Meaning

2017-07-09 Thread kdevel via Digitalmars-d-learn
On Sunday, 9 July 2017 at 15:10:56 UTC, ag0aep6g wrote: On 07/09/2017 03:51 PM, kdevel wrote: On Sunday, 9 July 2017 at 10:32:23 UTC, ag0aep6g wrote: [...] A null char* is not a proper C string. A C string is a sequence of storage units containing legitimate character values of which the

Re: Using lazy code to process large files

2017-08-02 Thread kdevel via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 11:44:30 UTC, Martin Drašar wrote: Thank you for any hint. 1 import std.stdio; 2 import std.string; 3 import std.algorithm; 4 import std.conv; 5 6 void main () 7 { 8auto input = File("input.csv"); 9 1

Re: Using lazy code to process large files

2017-08-02 Thread kdevel via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 13:45:01 UTC, Steven Schveighoffer wrote: As Daniel said, using byCodeUnit will help. stripLeft seems to autodecode even when fed with CodeUnits. How do I prevent this? 1 void main () 2 { 3import std.stdio; 4import std.string;

Re: Using lazy code to process large files

2017-08-02 Thread kdevel via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 15:52:13 UTC, Steven Schveighoffer wrote: [...] First, as a tip, please post either a link to a paste site, or don't put the line numbers. It's much easier to copy-paste your code into an editor if you don't have the line numbers. With pleasure. [...] If we

Re: Using lazy code to process large files

2017-08-02 Thread kdevel via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 17:37:09 UTC, Steven Schveighoffer wrote: What is expected? What I see on the screen when I run my code is: [Ü] Upper case? What I see when I run your "working" code is: [?] Your terminal is incapable of rendering the Latin-1 encoding. The program prints

dmd (v2.075.0): fully static linking: undefined reference to `__tls_get_addr'

2017-08-19 Thread kdevel via Digitalmars-d-learn
test.d --- void main () { } --- $ dmd -c test.d $ cc -o test test.o -L/[...]/dmd2/linux/lib64 -lphobos2 -static -lpthread -lrt /[...]/dmd2/linux/lib64/libphobos2.a(sections_elf_shared_774_420.o): In function `_D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv': src/rt/sections_elf_shared.d:(.te

Re: dmd (v2.075.0): fully static linking: undefined reference to `__tls_get_addr'

2017-08-19 Thread kdevel via Digitalmars-d-learn
On Saturday, 19 August 2017 at 14:07:49 UTC, kdevel wrote: src/rt/sections_elf_shared.d:(.text._D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv[_D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv]+0x38): undefined reference to `__tls_get_addr' https://issues.dlang.org/show_bug.cgi?id=12268

Re: How to Skip some field/word in formattRead?

2017-09-17 Thread kdevel via Digitalmars-d-learn
On Sunday, 17 September 2017 at 13:53:26 UTC, Ky-Anh Huynh wrote: Is it possible to read just the second word from an input string and skip all others? "one two three".formattedRead!("%s %s", _, saveme) --- import std.range; auto saveme = "one two three".split.array [2]; ---

Re: formattedRead can't work with tab delimiter input

2017-09-19 Thread kdevel via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 13:28:22 UTC, Ky-Anh Huynh wrote: Hi, I want to read two fields from STDIN string key; double value; line_st.formattedRead!"%s %f"(key, value); Well it's so different from C. I would use this: --- auto t = line_st.split.join (' '); t.formattedRead

Re: non-block reading from pipe stdout

2017-10-03 Thread kdevel via Digitalmars-d-learn
On Tuesday, 3 October 2017 at 00:22:28 UTC, Oleg B wrote: but get error "Resource temporarily unavailable". You get EAGAIN because there is no data available at the time of reading. From the manpage of read: ERRORS EAGAIN Non-blocking I/O has been selected using O_NONBLOCK and no d

Re: non-block reading from pipe stdout

2017-10-03 Thread kdevel via Digitalmars-d-learn
On Tuesday, 3 October 2017 at 11:36:28 UTC, Oleg B wrote: EAGAIN Non-blocking I/O has been selected using O_NONBLOCK and no data was immediately available for reading. And I can't check this without using exception handling? Your programm shall not read before data is a

Re: non-block reading from pipe stdout

2017-10-03 Thread kdevel via Digitalmars-d-learn
On Tuesday, 3 October 2017 at 12:20:09 UTC, Oleg B wrote: while (!tryWait(pp.pid).terminated) { auto cnt = read(fd, buf.ptr, buf.length); // C-style reading if (cnt == -1 && errno == EAGAIN) // C-style error checking yield();

Re: Assert and undefined behavior

2017-10-12 Thread kdevel via Digitalmars-d-learn
On Thursday, 12 October 2017 at 15:37:23 UTC, John Burton wrote: C++ compilers can and do perform such optimizations so I was wondering if assert in D could cause such behavior according to the spec. In the context of ISO-C++ it is meaningless to reason about the "actual behavior" of a non-co

Re: Why do I have to cast arguments from int to byte?

2017-10-12 Thread kdevel via Digitalmars-d-learn
On Wednesday, 11 October 2017 at 07:09:26 UTC, Daniel Kozak wrote: You can avoid cast: void foo(T)(T bar){...} byte bar = 9; foo!byte(bar + byte(1)); Sure? --- void foo(T)(T bar) { } byte bar = 9; void main () { foo!byte(bar + byte(1)); } --- byte2.d(7): Error: function byte2.foo!byte.foo

Re: Assert and undefined behavior

2017-10-12 Thread kdevel via Digitalmars-d-learn
On Thursday, 12 October 2017 at 20:27:03 UTC, Jonathan M Davis wrote: On Thursday, October 12, 2017 20:15:41 kdevel via --- void main () { assert (false); } --- qualifies as "invalid, and therefore has undefined behaviour." A statement, which makes no sense to me. Either it is a "debuggin

Re: Why do I have to cast arguments from int to byte?

2017-10-13 Thread kdevel via Digitalmars-d-learn
On Friday, 13 October 2017 at 07:47:55 UTC, Daniel Kozak wrote: but it works ok with immutable, so until you really need to change bar you can use immutable bar = 9; foo!byte(bar + 1); As Adam wrote two days ago: 'D doesn't do implicit narrowing conversion... so x + 1 becomes int, but then i

Re: Assert and undefined behavior

2017-10-13 Thread kdevel via Digitalmars-d-learn
On Friday, 13 October 2017 at 02:22:24 UTC, Jonathan M Davis wrote: You've told it that i should never be 3 at that point and that it's a bug if it is, and as such, it is free to assume that i is never 3 after the assertion even if the assertion is compiled out with -release - that is the only

Re: Assert and undefined behavior

2017-10-14 Thread kdevel via Digitalmars-d-learn
On Saturday, 14 October 2017 at 09:32:32 UTC, Timon Gehr wrote: Also, UB can and does sometimes mean that the program can execute arbitrary code. It's called "arbitrary code execution": https://en.wikipedia.org/wiki/Arbitrary_code_execution This confuses different levels of reasoning. In C/C++

<    1   2   3   4   >