Re: How should I return multiple const values from a function?

2023-01-02 Thread Charles Hixson via Digitalmars-d-learn
On 1/2/23 17:56, Paul Backus via Digitalmars-d-learn wrote: return Tuple!(const(Key), const(Value))(k, v); Great!  OK, now the code is:     auto    findFirst ()     {    if    (root is null)    {    Key k    =    Key.init;        Val v    =    Val.init;        return

Re: How should I return multiple const values from a function?

2023-01-02 Thread Charles Hixson via Digitalmars-d-learn
On 1/2/23 15:14, Paul Backus via Digitalmars-d-learn wrote: On Monday, 2 January 2023 at 22:53:13 UTC, Charles Hixson wrote: I want to return values of the template parameter type, so there doesn't seem to be any way to dup or idup them. It's hard to say where exactly you're going wrong if

Re: How should I return multiple const values from a function?

2023-01-02 Thread Charles Hixson via Digitalmars-d-learn
On 1/2/23 15:14, Paul Backus via Digitalmars-d-learn wrote: On Monday, 2 January 2023 at 22:53:13 UTC, Charles Hixson wrote: I want to return values of the template parameter type, so there doesn't seem to be any way to dup or idup them. It's hard to say where exactly you're going wrong if

How should I return multiple const values from a function?

2023-01-02 Thread Charles Hixson via Digitalmars-d-learn
I want to return values of the template parameter type, so there doesn't seem to be any way to dup or idup them.  I don't want the returned values to be able to be used to modify the values held in the table.  const out is an illegal parameter type.  dup doesn't work on ints. So I tried to

Re: Unexpected path of execution

2021-10-19 Thread Charles Hixson via Digitalmars-d-learn
Thank you.  That seems to have solved the problem (bar additional testing).  And also thanks for your recommendation to add to the index rather than casting the length.  It wasn't as "nice" to my eyes at first, but it's a cleaner answer. On 10/19/21 9:38 AM, Adam D Ruppe via

Unexpected path of execution

2021-10-19 Thread Charles Hixson via Digitalmars-d-learn
given this code fragment:             if    (i < (line.length - 3) )             {    writeln ("in c4: i = ", i, ", line.length = ", line.length);                   add2 (c4, line [i..i+4]); I get this result: in c4: i = 0, line.length = 2 core.exception.RangeError@source/freqs.d(32): Range

Re: template parameters :: fix

2021-09-03 Thread Charles Hixson via Digitalmars-d-learn
change:             {    rl.remove(i); to:            {    rl  =  rl.remove(i); -- Javascript is what you use to allow third party programs you don't know anything about and doing you know not what to run on your computer.

Re: template parameters

2021-09-02 Thread Charles Hixson via Digitalmars-d-learn
Thanks.  See below for what I did. On 8/29/21 5:05 PM, Ali Çehreli via Digitalmars-d-learn wrote: On 8/29/21 3:31 PM, Charles Hixson wrote: > Thanks.  I going to have to study: > > enum supportsCall = isIntegral!(typeof(T.init.%s())); > > > for awhile to make any sense of that, but it looks

Re: template parameters

2021-08-29 Thread Charles Hixson via Digitalmars-d-learn
Thanks.  I going to have to study: enum supportsCall = isIntegral!(typeof(T.init.%s())); for awhile to make any sense of that, but it looks like just what I was looking for. On 8/29/21 2:41 PM, Ali Çehreli via Digitalmars-d-learn wrote: On 8/29/21 11:32 AM, Charles H. wrote: I've set up

template parameters

2021-08-29 Thread Charles Hixson via Digitalmars-d-learn
I've set up a class template (so far untested) thus: class    AARL (T, ndx = "ndx")         if (isIntegral(T.init.ndx) ) If I'm correct, this should work for ndx an integer variable of T, but I'd really like T to be able to be anything which can be stored both in an array and in an associative

Re: auto: useful, annoying or bad practice?

2018-05-20 Thread Charles Hixson via Digitalmars-d
auto has its uses, but it's wildly overused, especially in library code and documentation, and really, really, *really* much so in documentation examples. On 05/01/2018 06:09 AM, Craig Dillabaugh via Digitalmars-d wrote: On Monday, 30 April 2018 at 21:11:07 UTC, Gerald wrote: I'll freely

Re: shared arrray problem

2016-11-21 Thread Charles Hixson via Digitalmars-d-learn
On 11/20/2016 12:41 PM, ag0aep6g via Digitalmars-d-learn wrote: On 11/20/2016 09:09 PM, Charles Hixson via Digitalmars-d-learn wrote: Thinking it over a bit more, the item returned would need to be a struct, but the struct wouldn't contain the array, it would just contain a reference

Re: shared arrray problem

2016-11-20 Thread Charles Hixson via Digitalmars-d-learn
On 11/20/2016 03:42 AM, ag0aep6g via Digitalmars-d-learn wrote: On 11/20/2016 04:34 AM, Charles Hixson via Digitalmars-d-learn wrote: Whether you would call the change "break things for your code" might be dubious. It would be effectively broken, even if technically my code

Re: shared arrray problem

2016-11-20 Thread Charles Hixson via Digitalmars-d-learn
On 11/20/2016 03:42 AM, ag0aep6g via Digitalmars-d-learn wrote: On 11/20/2016 04:34 AM, Charles Hixson via Digitalmars-d-learn wrote: Whether you would call the change "break things for your code" might be dubious. It would be effectively broken, even if technically my code

Re: shared arrray problem

2016-11-19 Thread Charles Hixson via Digitalmars-d-learn
On 11/19/2016 05:52 PM, ag0aep6g via Digitalmars-d-learn wrote: On 11/20/2016 01:33 AM, Charles Hixson via Digitalmars-d-learn wrote: Yes. I was hoping someone would pop up with some syntax making the array, but not its contents, const or immutable, which I couldn't figure out how to do

Re: shared arrray problem

2016-11-19 Thread Charles Hixson via Digitalmars-d-learn
On 11/19/2016 01:50 PM, ag0aep6g via Digitalmars-d-learn wrote: On 11/19/2016 10:26 PM, Charles Hixson via Digitalmars-d-learn wrote: It's worse than that, if they modify the length the array may be reallocated in RAM so that the pointers held by the containing class do not point to the changed

Re: shared arrray problem

2016-11-19 Thread Charles Hixson via Digitalmars-d-learn
On 11/19/2016 11:10 AM, Nicolas Gurrola via Digitalmars-d-learn wrote: On Saturday, 19 November 2016 at 18:51:05 UTC, Charles Hixson wrote: ubyte[]header()@property {return fHead[4..$];} This method should do what you want. You are only returning a slice of the fHead

Re: fPIC Error

2016-11-19 Thread Charles Hixson via Digitalmars-d-learn
On 11/18/2016 10:35 PM, deadalnix via Digitalmars-d-learn wrote: On Thursday, 3 November 2016 at 06:11:48 UTC, rikki cattermole wrote: [Environment32] DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu -L--export-dynamic -fPIC

shared arrray problem

2016-11-19 Thread Charles Hixson via Digitalmars-d-learn
I have a piece of code that looks thus: /**Returns an editable file header missing the header length and data * length portions. Those cannot be edited by a routine outside this class. * Access to them is available via the lenHead and lenRec functions. * Warning: Do NOT change the

Re: Is it possible to store different generic types in ex. an

2016-11-12 Thread Charles Hixson via Digitalmars-d-learn
On 11/09/2016 07:46 AM, Is it possible to store different generic types? via Digitalmars-d-learn wrote: On Wednesday, 9 November 2016 at 15:44:59 UTC, Is it possible to store different generic types? wrote: Is it possible to store different generic types in ex. somekind of container such as an

Re: problem with isnan

2016-11-11 Thread Charles Hixson via Digitalmars-d-learn
On 11/11/2016 01:34 PM, John C via Digitalmars-d-learn wrote: On Friday, 11 November 2016 at 20:55:52 UTC, Charles Hixson wrote: Thank you. Unfortunately: importstd.math; ... assert(isNan (c.curActivation), "cell has unexpected curActivation:

Re: problem with isnan

2016-11-11 Thread Charles Hixson via Digitalmars-d-learn
On 11/11/2016 10:31 AM, pineapple via Digitalmars-d-learn wrote: On Thursday, 10 November 2016 at 16:47:30 UTC, Adam D. Ruppe wrote: On Thursday, 10 November 2016 at 16:41:56 UTC, Charles Hixson wrote: It's *supposed* to be nan, and the assert message reports that it is, but it should pass

Re: problem with isnan

2016-11-10 Thread Charles Hixson via Digitalmars-d-learn
On 11/10/2016 08:47 AM, Adam D. Ruppe via Digitalmars-d-learn wrote: On Thursday, 10 November 2016 at 16:41:56 UTC, Charles Hixson wrote: It's *supposed* to be nan, and the assert message reports that it is, but it should pass the assert test, not throw an assertion. What am I doing wrong?

problem with isnan

2016-11-10 Thread Charles Hixson via Digitalmars-d-learn
The line: assert(isnan (c.curActivation), "cell has unexpected curActivation: %s".format(c.curActivation)); throws the exception: core.exception.AssertError@cell.d(285): cell has unexpected curActivation: nan and I've looked at it backwards and forwards and don't understand why.

Re: Sockets and using them...

2016-11-07 Thread Charles Hixson via Digitalmars-d-learn
On 11/05/2016 11:02 PM, Era Scarecrow via Digitalmars-d-learn wrote: So I've got a project where I want to create basically a decentralized chat program where every program is a host and a client. When you connect all connections can go through to route the chat to everyone else. So to

Re: strange -fPIC compilation error

2016-11-01 Thread Charles Hixson via Digitalmars-d-learn
On 11/01/2016 10:34 AM, bachmeier via Digitalmars-d-learn wrote: On Tuesday, 1 November 2016 at 17:23:54 UTC, Charles Hixson wrote: On 11/01/2016 12:52 AM, Nordlöw via Digitalmars-d-learn wrote: On Tuesday, 1 November 2016 at 07:15:19 UTC, Mike Parker wrote: but dmd -defaultlib=libphobos2.so

Re: strange -fPIC compilation error

2016-11-01 Thread Charles Hixson via Digitalmars-d-learn
On 11/01/2016 12:52 AM, Nordlöw via Digitalmars-d-learn wrote: On Tuesday, 1 November 2016 at 07:15:19 UTC, Mike Parker wrote: but dmd -defaultlib=libphobos2.so -fPIC test.d works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I can deal with it

Re: strange -fPIC compilation error

2016-10-31 Thread Charles Hixson via Digitalmars-d-learn
On 10/31/2016 12:31 PM, Daniel Kozak via Digitalmars-d-learn wrote: Dne 31.10.2016 v 20:20 Charles Hixson via Digitalmars-d-learn napsal(a): ... but dmd -defaultlib=libphobos2.so -fPIC test.d works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I

Re: strange -fPIC compilation error

2016-10-31 Thread Charles Hixson via Digitalmars-d-learn
On 10/31/2016 11:23 AM, Daniel Kozak via Digitalmars-d-learn wrote: Dne 31.10.2016 v 18:06 Charles Hixson via Digitalmars-d-learn napsal(a): On 10/31/2016 09:26 AM, Charles Hixson via Digitalmars-d-learn wrote: On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote: Dne

Re: strange -fPIC compilation error

2016-10-31 Thread Charles Hixson via Digitalmars-d-learn
On 10/31/2016 09:26 AM, Charles Hixson via Digitalmars-d-learn wrote: On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote: Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a): Well, that certainly changed the error messages. With dmd -defaultlib=/usr/lib

Re: strange -fPIC compilation error

2016-10-31 Thread Charles Hixson via Digitalmars-d-learn
On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote: Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a): Well, that certainly changed the error messages. With dmd -defaultlib=/usr/lib/x86_64-linux-gnu/libphobos2.so test.d I get: /usr/include/dmd/druntime

Re: strange -fPIC compilation error

2016-10-30 Thread Charles Hixson via Digitalmars-d-learn
On 10/30/2016 05:14 PM, Lodovico Giaretta via Digitalmars-d-learn wrote: On Monday, 31 October 2016 at 00:08:59 UTC, Charles Hixson wrote: So now I removed the repository version of dmd and dub, downloaded DMD64 D Compiler v2.072.0-b2, used dkpg to install it, and appear to get the same

Re: strange -fPIC compilation error

2016-10-30 Thread Charles Hixson via Digitalmars-d-learn
, Charles Hixson via Digitalmars-d-learn wrote: dmd --version DMD64 D Compiler v2.071.2 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright on debian testing. dub is installed via apt-get. Should I revert to an earlier version? Or what? The program: importstd.stdio; voidmain

Re: strange -fPIC compilation error

2016-10-30 Thread Charles Hixson via Digitalmars-d-learn
Just as a test I tried it with ldc, and, as expected, there wasn't any problem. On 10/30/2016 11:02 AM, Charles Hixson via Digitalmars-d-learn wrote: dmd --version DMD64 D Compiler v2.071.2 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright on debian testing. dub is installed

Re: strange -fPIC compilation error

2016-10-30 Thread Charles Hixson via Digitalmars-d-learn
On 10/30/2016 04:03 PM, Lodovico Giaretta via Digitalmars-d-learn wrote: On Sunday, 30 October 2016 at 18:02:28 UTC, Charles Hixson wrote: dmd --version DMD64 D Compiler v2.071.2 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright on debian testing. dub is installed via

strange -fPIC compilation error

2016-10-30 Thread Charles Hixson via Digitalmars-d-learn
dmd --version DMD64 D Compiler v2.071.2 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright on debian testing. dub is installed via apt-get. Should I revert to an earlier version? Or what? The program: importstd.stdio; voidmain() {//int[]t1; //t1~=

Re: Why 16Mib static array size limit?

2016-08-16 Thread Charles Hixson via Digitalmars-d
On 08/16/2016 01:49 PM, Steven Schveighoffer via Digitalmars-d wrote: On 8/16/16 4:11 PM, Yuxuan Shui wrote: On Tuesday, 16 August 2016 at 17:51:13 UTC, Johan Engelen wrote: On Tuesday, 16 August 2016 at 01:28:05 UTC, Ali Çehreli wrote: With ldc2, the best option is to go with a dynamic

Re: Multi-Thread message passing approach

2016-08-16 Thread Charles Hixson via Digitalmars-d-learn
On 08/16/2016 07:21 AM, Kagamin via Digitalmars-d-learn wrote: On Monday, 15 August 2016 at 01:53:33 UTC, Charles Hixson wrote: If I modify the code to attempt to pass a Tid[] as a member of struct Start I get: /usr/include/dmd/phobos/std/concurrency.d(603): Error: static assert "Aliases

Re: Multi-Thread message passing approach

2016-08-15 Thread Charles Hixson via Digitalmars-d-learn
I misunderstood the problem. The problem was that a dynamically sized array cannot be sent as a message. So this works: import std.concurrency; import std.stdio; import core.thread; enum tidMax = 10; struct Start { int tidCnt = 0; Tid[tidMax] tids; } struct Msg { int

Re: Multi-Thread message passing approach

2016-08-14 Thread Charles Hixson via Digitalmars-d-learn
n't happen to be detected by the library. On 08/14/2016 07:44 AM, Charles Hixson via Digitalmars-d-learn wrote: This is an approach to n x n thread message passing. The idea is that each thread should be able to pass messages to any other thread. The only alternative I've come up with involves the m

Re: Multi-Thread message passing approach

2016-08-14 Thread Charles Hixson via Digitalmars-d-learn
On 08/14/2016 07:44 AM, Charles Hixson via Digitalmars-d-learn wrote: This is an approach to n x n thread message passing. The idea is that each thread should be able to pass messages to any other thread. The only alternative I've come up with involves the main thread handling each message

Re: Is this the best way to share Tids between threads?

2016-08-14 Thread Charles Hixson via Digitalmars-d
Sorry this ended up here rather than at learn. I followed up there with something more explicit. See "Multi-Thread message passing approach" in learn. The problem here is that the threads will be doing the same thing, sort of, modulus an integer. And the number of them should be set at run

Multi-Thread message passing approach

2016-08-14 Thread Charles Hixson via Digitalmars-d-learn
This is an approach to n x n thread message passing. The idea is that each thread should be able to pass messages to any other thread. The only alternative I've come up with involves the main thread handling each message. Is that a better approach? Is there a better way to pass lists of

Is this the best way to share Tids between threads?

2016-08-13 Thread Charles Hixson via Digitalmars-d
I'm trying to figure out the best way to have multiple threads that can each send messages to the other threads. I've come up with two basic approaches, one uses the main thread as a relay, and the other uses a shared array of Tid...thus: importstd.concurrency; importstd.stdio;

Re: how to declare an immutable class?

2016-08-12 Thread Charles Hixson via Digitalmars-d-learn
Thank you both. On 08/12/2016 01:35 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Friday, August 12, 2016 05:25:45 Mike Parker via Digitalmars-d-learn wrote: immutable class Foo { ... } is the same as declaring every member of Foo as immutable, just as final class Foo { ... } makes

Re: how to declare an immutable class?

2016-08-11 Thread Charles Hixson via Digitalmars-d-learn
On 08/11/2016 06:33 PM, Mike Parker via Digitalmars-d-learn wrote: On Friday, 12 August 2016 at 00:44:31 UTC, Charles Hixson wrote: A way around this, which may be the same as the approach used by string was: alias immutable(Msg_)Msg; classMsg_ { ... This is exactly what Jonathan

Re: how to declare an immutable class?

2016-08-11 Thread Charles Hixson via Digitalmars-d-learn
before this solution On 08/11/2016 10:56 AM, Charles Hixson via Digitalmars-d-learn wrote: I want to declare a class all instances of which will be immutable, and all references to which will be inherently immutable (so that I don't need to slip a huge number of "immutable" statements

how to declare an immutable class?

2016-08-11 Thread Charles Hixson via Digitalmars-d-learn
I want to declare a class all instances of which will be immutable, and all references to which will be inherently immutable (so that I don't need to slip a huge number of "immutable" statements in my code). This is surely possible, because string acts just that way, but I can't figure out

arrays, mmu, addressing choices

2016-08-08 Thread Charles Hixson via Digitalmars-d-learn
I have a rather large array that I intend to build. but much of it will only occasionally be used. Will the unused sections automatically be paged out? If it matters my system is Debian Linux. This array will be indexed by a ulong. Is there any reasonable maximum size? I've considered

Re: Why D is not popular enough?

2016-08-01 Thread Charles Hixson via Digitalmars-d
On 08/01/2016 09:37 AM, eugene via Digitalmars-d wrote: On Monday, 1 August 2016 at 15:31:35 UTC, Emre Temelkuran wrote: For years, i was travelling along Golang, Rust, Perl, Ruby, Python, PHP, JScript, JVM Languages. Lastly Crystal Lang and Nimrod, Julia, Haskell, Swift and many more that i

Re: Make D language as Apache foundation project

2016-08-01 Thread Charles Hixson via Digitalmars-d
On 08/01/2016 08:56 AM, Emre Temelkuran via Digitalmars-d wrote: On Wednesday, 27 July 2016 at 13:28:04 UTC, Adam D. Ruppe wrote: On Wednesday, 27 July 2016 at 13:08:17 UTC, eugene wrote: Hello everyone, why not to make a D language as a project of Apache foundation as it happened to groovy?

Re: Overflows in Phobos

2016-07-29 Thread Charles Hixson via Digitalmars-d
On 07/26/2016 07:36 AM, ketmar via Digitalmars-d wrote: On Tuesday, 26 July 2016 at 14:28:48 UTC, Timon Gehr wrote: "The expression assert(0) is a special case; it signifies that it is unreachable code. [...] The optimization and code generation phases of compilation may assume that it is

Re: randomIO, std.file, core.stdc.stdio

2016-07-27 Thread Charles Hixson via Digitalmars-d-learn
On 07/27/2016 06:46 AM, Rene Zwanenburg via Digitalmars-d-learn wrote: On Wednesday, 27 July 2016 at 02:20:57 UTC, Charles Hixson wrote: O, dear. It was sounding like such an excellent approach until this last paragraph, but growing the file is going to be one of the common operations.

Re: randomIO, std.file, core.stdc.stdio

2016-07-26 Thread Charles Hixson via Digitalmars-d-learn
On 07/26/2016 12:53 PM, Adam D. Ruppe via Digitalmars-d-learn wrote: On Tuesday, 26 July 2016 at 19:30:35 UTC, Charles Hixson wrote: It looks as if the entire file is stored in memory, which is not at all what I want, but I also can't really believe that's what's going on. It is just mapped

Re: randomIO, std.file, core.stdc.stdio

2016-07-26 Thread Charles Hixson via Digitalmars-d-learn
On 07/26/2016 11:31 AM, Steven Schveighoffer via Digitalmars-d-learn wrote: On 7/26/16 1:57 PM, Charles Hixson via Digitalmars-d-learn wrote: Thanks. Since there isn't any excess overhead I guess I'll use stdio. Buffering, however, isn't going to help at all since I'm doing randomIO. I know

Re: randomIO, std.file, core.stdc.stdio

2016-07-26 Thread Charles Hixson via Digitalmars-d-learn
On 07/26/2016 10:18 AM, Steven Schveighoffer via Digitalmars-d-learn wrote: On 7/26/16 12:58 PM, Charles Hixson via Digitalmars-d-learn wrote: Ranges aren't free, are they? If so then I should probably use stdfile, because that is probably less likely to change than core.stdc.stdio. Do you

Re: randomIO, std.file, core.stdc.stdio

2016-07-26 Thread Charles Hixson via Digitalmars-d-learn
On 07/26/2016 05:31 AM, Steven Schveighoffer via Digitalmars-d-learn wrote: On 7/25/16 9:19 PM, Charles Hixson via Digitalmars-d-learn wrote: On 07/25/2016 05:18 PM, ketmar via Digitalmars-d-learn wrote: On Monday, 25 July 2016 at 18:54:27 UTC, Charles Hixson wrote: Are there reasons why one

Re: randomIO, std.file, core.stdc.stdio

2016-07-26 Thread Charles Hixson via Digitalmars-d-learn
On 07/25/2016 09:22 PM, ketmar via Digitalmars-d-learn wrote: On Tuesday, 26 July 2016 at 04:05:22 UTC, Charles Hixson wrote: Yes, but I really despise the syntax they came up with. It's probably good if most of your I/O is ranges, but mine hasn't yet ever been. (Combining ranges with random

Re: randomIO, std.file, core.stdc.stdio

2016-07-25 Thread Charles Hixson via Digitalmars-d-learn
On 07/25/2016 07:11 PM, ketmar via Digitalmars-d-learn wrote: On Tuesday, 26 July 2016 at 01:19:49 UTC, Charles Hixson wrote: then I will prefer the core.stdc.stdio approach. I find it's appearance extremely much cleaner... only if you are really used to write C code. when you see pointer,

Re: randomIO, std.file, core.stdc.stdio

2016-07-25 Thread Charles Hixson via Digitalmars-d-learn
On 07/25/2016 05:18 PM, ketmar via Digitalmars-d-learn wrote: On Monday, 25 July 2016 at 18:54:27 UTC, Charles Hixson wrote: Are there reasons why one would use rawRead and rawWrite rather than fread and fwrite when doiing binary random io? What are the advantages? In particular, if one is

randomIO, std.file, core.stdc.stdio

2016-07-25 Thread Charles Hixson via Digitalmars-d-learn
Are there reasons why one would use rawRead and rawWrite rather than fread and fwrite when doiing binary random io? What are the advantages? In particular, if one is reading and writing structs rather than arrays or ranges, are there any advantages?

Re: Our docs should be more beautiful

2016-07-21 Thread Charles Hixson via Digitalmars-d
I think the Python docs looks better and are more useful...but the older Python docs were even better. Sometimes fancier HTML just makes things less useful. That said, I think that when feasible docs should be auto-generated from code included within the code files. More like ddoc or

Re: How to open file with exclusive lock?

2016-07-12 Thread Charles Hixson via Digitalmars-d-learn
On 07/12/2016 03:54 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Jul 12, 2016 at 03:40:36PM -0700, Charles Hixson via Digitalmars-d-learn wrote: [...] OK. It's not possible without OS support. Agreed. And I don't want to get into C calls, but rather to use the mechanisms that D

Re: How to open file with exclusive lock?

2016-07-12 Thread Charles Hixson via Digitalmars-d-learn
On 07/12/2016 12:05 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Jul 12, 2016 at 11:54:18AM -0700, Charles Hixson via Digitalmars-d-learn wrote: I want to open a file with an exclusive lock. It would be important that no other thread be able to access the file in write mode

How to open file with exclusive lock?

2016-07-12 Thread Charles Hixson via Digitalmars-d-learn
I want to open a file with an exclusive lock. It would be important that no other thread be able to access the file in write mode, and desirable that no other thread be able to access the file in read mode. (Ditto for other processes.) stdio.file.lock (or is it stdio.file.File.lock?) seems

Re: D is crap

2016-07-11 Thread Charles Hixson via Digitalmars-d
Garbage collection allows many syntax "liberalizations" that lack of garbage collection renders either impossible or highly dangerous. (In this definition of "garbage collection" I'm including variations like reference counting.) For an example of this consider the dynamic array type. You

Re: Should we add another SmallArray to DMD?

2016-07-07 Thread Charles Hixson via Digitalmars-d
On 07/07/2016 03:51 AM, Guillaume Chatelet via Digitalmars-d wrote: On Thursday, 7 July 2016 at 07:56:44 UTC, Stefan Koch wrote: On Thursday, 7 July 2016 at 06:39:19 UTC, Guillaume Chatelet wrote: On Tuesday, 5 July 2016 at 19:41:18 UTC, Guillaume Chatelet wrote: DMD currently provides the

Re: How to get current time as long or ulong?

2016-07-06 Thread Charles Hixson via Digitalmars-d-learn
On 07/06/2016 10:32 AM, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Jul 06, 2016 at 10:19:19AM -0700, Charles Hixson via Digitalmars-d-learn wrote: [...] The same time needs to be used for two different purposes (or I have to keep two separate times). One time is used during

Re: How to get current time as long or ulong?

2016-07-06 Thread Charles Hixson via Digitalmars-d-learn
On 07/05/2016 05:23 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, July 05, 2016 12:51:54 Charles Hixson via Digitalmars-d-learn wrote: On 07/05/2016 11:43 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, July 05, 2016 11:16:31 Charles Hixson via Digitalmars-d

Re: How to get current time as long or ulong?

2016-07-05 Thread Charles Hixson via Digitalmars-d-learn
is going to be important. For the second use I could use a much lower precision timer, but that would mean using two separate times for each item. On 07/05/2016 05:10 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, July 05, 2016 16:18:19 Charles Hixson via Digitalmars-d-learn

Re: How to get current time as long or ulong?

2016-07-05 Thread Charles Hixson via Digitalmars-d-learn
I guess I was expressing myself poorly, probably due to muddled thinking about the representation of time. Based on various hints from you and others my current guess is that I should use: longnow() { returnClock.currTime().stdTime;} IIUC this should return the current system

Re: How to get current time as long or ulong?

2016-07-05 Thread Charles Hixson via Digitalmars-d-learn
On 07/05/2016 11:43 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, July 05, 2016 11:16:31 Charles Hixson via Digitalmars-d-learn wrote: What I'm looking for is the opposite of the "FromUnixTime" function. SysTime has toUnixTime, which is right above fr

How to get current time as long or ulong?

2016-07-05 Thread Charles Hixson via Digitalmars-d-learn
I've been reading std.datetime documentation backwards and forwards, but if the information is there, I've been missing it. How do I get the current time as a long? Clock.currTime() returns a SysTime, and while currently I can convert that to a long, this is because I looked into the code.

Re: D is almost the exact language I need...

2016-07-03 Thread Charles Hixson via Digitalmars-d
On 07/03/2016 01:31 AM, Walter Bright via Digitalmars-d wrote: On 7/3/2016 12:21 AM, Charles Hixson via Digitalmars-d wrote: I do wish that phobos included a D wrapper around SQLite, There was one recently announced. Thanks. I missed the announcement. I'd also like to be able to depend

Re: D is almost the exact language I need...

2016-07-03 Thread Charles Hixson via Digitalmars-d
FWIW, I feel that the elaboration of the template language doesn't serve me well. That's my use case, so I try to ignore it as much as possible, but phobos has been re-written to be much less intelligible to me. I'm sure that many people find the inclusion of ranges into everything useful,

Re: UTF-8 Everywhere

2016-06-20 Thread Charles Hixson via Digitalmars-d
On 06/19/2016 11:44 PM, Walter Bright via Digitalmars-d wrote: On 6/19/2016 11:36 PM, Charles Hixson via Digitalmars-d wrote: To me it seems that a lot of the time processing is more efficient with UCS-4 (what I call utf-32). Storage is clearly more efficient with utf-8, but access is more

Re: UTF-8 Everywhere

2016-06-20 Thread Charles Hixson via Digitalmars-d
To me it seems that a lot of the time processing is more efficient with UCS-4 (what I call utf-32). Storage is clearly more efficient with utf-8, but access is more direct with UCS-4. I agree that utf-8 is generally to be preferred where it can be efficiently used, but that's not everywhere.

Re: Andrei's list of barriers to D adoption

2016-06-07 Thread Charles Hixson via Digitalmars-d
On 06/05/2016 09:17 PM, Adam D. Ruppe via Digitalmars-d wrote: On Monday, 6 June 2016 at 02:30:55 UTC, Pie? wrote: Duh! The claim is made that D can work without the GC... but that's a red herring... If you take about the GC what do you have? Like 90% of the language, still generally nicer

stdout.flush

2016-05-25 Thread Charles Hixson via Digitalmars-d-learn
Using: dmd --version DMD64 D Compiler v2.071.0 on debian Linux, and importing: importstd.stdio; the line: flush(); causes: nt.d(29): Error: undefined identifier 'flush', did you mean function 'fflush'? This appears solved by doing stdout.flush; (compiles, but I'm still writing the

Re: More binary I/O problems

2016-04-08 Thread Charles Hixson via Digitalmars-d-learn
On 04/08/2016 07:42 PM, Basile B. via Digitalmars-d-learn wrote: On Friday, 8 April 2016 at 20:58:06 UTC, Charles Hixson wrote: [...] And that worked, but suddenly (after a compiler upgrade, did that matter? I'd also changed the program, though in ways that shouldn't have affected this.) it

More binary I/O problems

2016-04-08 Thread Charles Hixson via Digitalmars-d-learn
On 03/25/2016 11:32 AM, Adam D. Ruppe via Digitalmars-d-learn wrote: On Friday, 25 March 2016 at 18:25:28 UTC, Charles Hixson wrote: But when I try to cast a Chnk to a ubyte[], I get an error, and rawWrite takes a generic array of anything... you should be able to rawWrite((_object)[0 ..

Re: Decompressing bzip2

2016-04-05 Thread Charles Hixson via Digitalmars-d-learn
On 04/05/2016 03:33 PM, Mike Parker via Digitalmars-d-learn wrote: On Tuesday, 5 April 2016 at 19:27:20 UTC, Charles Hixson wrote: ... Are you asserting that scope is soon to be officially deprecated? I'm finding "shouldn't really be used at all anymore" a bit of a worrying statement, as I

Re: Decompressing bzip2

2016-04-05 Thread Charles Hixson via Digitalmars-d-learn
On 04/04/2016 04:38 PM, Mike Parker via Digitalmars-d-learn wrote: On Monday, 4 April 2016 at 21:32:10 UTC, stunaep wrote: Can you please explain what the scope keyword does and if there scope was originally intended to be used primarily with classes in order to get deterministic

Re: unicode confusion--An answer

2016-04-04 Thread Charles Hixson via Digitalmars-d-learn
I was writing my output to two different files. Only one of them was set to utf-8, the other must have been some other encoding, because when I set the encoding to utf-8 everything cleared up. On 04/04/2016 04:04 PM, Charles Hixson via Digitalmars-d-learn wrote: Well, at least I think

unicode confusion

2016-04-04 Thread Charles Hixson via Digitalmars-d-learn
Well, at least I think that it's unicode confusion. When a store values into a string (in an array of structs) and then compare it against itself, it compares fine, and if I write it out at that point it writes out fine. And validate says it's good unicode. But later... valid = true, len =

Re: rawWrite of a struct suggestions

2016-03-26 Thread Charles Hixson via Digitalmars-d-learn
OK, after removing a few bugs, preliminary checks say that this works perfectly. Thanks again, as I never would have even considered that approach. On 03/25/2016 12:24 PM, Charles Hixson via Digitalmars-d-learn wrote: On 03/25/2016 11:32 AM, Adam D. Ruppe via Digitalmars-d-learn wrote

Re: rawWrite of a struct suggestions

2016-03-25 Thread Charles Hixson via Digitalmars-d-learn
On 03/25/2016 11:32 AM, Adam D. Ruppe via Digitalmars-d-learn wrote: On Friday, 25 March 2016 at 18:25:28 UTC, Charles Hixson wrote: But when I try to cast a Chnk to a ubyte[], I get an error, and rawWrite takes a generic array of anything... you should be able to rawWrite((_object)[0 ..

rawWrite of a struct suggestions

2016-03-25 Thread Charles Hixson via Digitalmars-d-learn
I've got a simple struct: structChnk { ulongid; char[20]wrd; ubytelength; ...<--various utility functions and constructors } That I'm trying to write to a file. I want to use an unformatted read/write because I want this to be a random access file. But

is increment on shared ulong atomic operation?

2016-02-07 Thread Charles Hixson via Digitalmars-d-learn
If I define a shared ulong variable, is increment an atomic operation? E.g. shared ulong t; ... t++; It seems as if it ought to be, but it could be split into read, increment, store. I started off defining a shared struct, but that seems silly, as if the operations defined within a shared

Re: is increment on shared ulong atomic operation?

2016-02-07 Thread Charles Hixson via Digitalmars-d-learn
Thanks, that's what I needed to know. I'm still going to do it as a class, but now only the inc routine needs to be handled specially. (The class is so that other places where the value is used don't even need to know that it's special. And so that instances are easy to share between

Re: Proposal: Database Engine for D

2016-01-04 Thread Charles Hixson via Digitalmars-d
FWIW, were I proposing a "Database Engine for D" I'd be proposing a B+Tree that was restricted to storing explicit data (no pointers or other indirection...including strings, you'd need to specify fixed size arrays of char, wchar, or dchar). There would be one "type"/file, and the "type"

Re: Wishlist for D

2015-12-15 Thread Charles Hixson via Digitalmars-d
On 12/14/2015 01:27 PM, tsbockman via Digitalmars-d wrote: On Sunday, 13 December 2015 at 11:25:37 UTC, Ola Fosheim Grøstad wrote: On Sunday, 13 December 2015 at 11:18:31 UTC, Robert burner Schadek wrote: On Saturday, 12 December 2015 at 22:57:55 UTC, Ola Fosheim Grøstad wrote: 2.

Re: Wishlist for D

2015-12-12 Thread Charles Hixson via Digitalmars-d
A "batteries included" extension to phobos modeled after the Python modules. Esp. I'd like a standard linkage to Sqlite via D rather than C, but I'm sure that other have other most desired libraries. Additionally, I'd like fewer language changes. D is a great language now, and changes, while

Re: Wishlist for D

2015-12-12 Thread Charles Hixson via Digitalmars-d
On 12/12/2015 03:47 PM, Jack Stouffer via Digitalmars-d wrote: On Saturday, 12 December 2015 at 19:55:27 UTC, Charles Hixson wrote: Now I'll occasionally use it, but I so often need to iterate over multiple arrays that I use indexing much more often Why not use foreach(ref a, ref b, ref c;

Re: error detected at """ ch in unicode.C """ Library error?

2015-10-23 Thread Charles Hixson via Digitalmars-d-learn
On 10/23/2015 04:33 AM, rumbu via Digitalmars-d-learn wrote: My opinion is to use the Tango's unicodedata.d module to obtain the unicode category, std.uni does not provide such functionality. This module does not have any dependency, therefore you can just use it directly:

Re: error detected at """ ch in unicode.C """ Library error?

2015-10-22 Thread Charles Hixson via Digitalmars-d-learn
On 10/21/2015 06:21 PM, Charles Hixson via Digitalmars-d-learn wrote: To me this looks like a library error, but I'm not sure. Any suggestions importstd.uni; chargcCat1(dchar ch) { if(ch in unicode.L)return'L';// Letter if(ch in unicode.M

Re: std.uni general character category

2015-10-21 Thread Charles Hixson via Digitalmars-d-learn
On 10/20/2015 10:38 AM, Charles Hixson via Digitalmars-d-learn wrote: In std.uni (D Lib 2.068.2) I can no longer see how to get the general category code for a character. Does anyone know what the currently supported way to do that is? I thought I remembered that I used to be able

error detected at """ ch in unicode.C """ Library error?

2015-10-21 Thread Charles Hixson via Digitalmars-d-learn
To me this looks like a library error, but I'm not sure. Any suggestions importstd.uni; chargcCat1(dchar ch) { if(ch in unicode.L)return'L';//Letter if(ch in unicode.M)return'M';//Mask if(ch in unicode.C)

std.uni general character category

2015-10-20 Thread Charles Hixson via Digitalmars-d-learn
In std.uni (D Lib 2.068.2) I can no longer see how to get the general category code for a character. Does anyone know what the currently supported way to do that is?

Re: Replacement of std.stream

2015-07-19 Thread Charles Hixson via Digitalmars-d-learn
On Monday, 29 June 2015 at 12:00:14 UTC, Jonathan M Davis wrote: On Sunday, June 28, 2015 11:14:57 Baz via Digitalmars-d-learn wrote: On Sunday, 28 June 2015 at 05:04:48 UTC, DlangLearner wrote: I will convert a Java program into D. The original Java code is based on the class

  1   2   >