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: 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: 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

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

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: 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: 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: 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.

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: 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

What is the std.stream replacement?

2015-07-19 Thread Charles Hixson via Digitalmars-d-learn
I have DMD64 D Compiler v2.067.1 installed, and in the documentation of phobos what it says about std.stream is don't use it on new code. It doesn't, however, appear to offer any replacement. Certainly std.file, std.stdio, and std.path aren't replacements. So what *is* the appropriate

std.concurrent Tid vector initialization problem

2015-06-30 Thread Charles Hixson via Digitalmars-d-learn
I'm planning an application where a series of threads each need to be aware of the Tids of all the others. The number won't be known at compile time, but that doesn't seem to change the design. All I've been able to come up with is a pair of loops, one to spawn the threads, and collect their

Re: std.concurrent Tid vector initialization problem

2015-06-30 Thread Charles Hixson via Digitalmars-d-learn
On Sunday, 28 June 2015 at 09:59:29 UTC, Marc Schütz wrote: On Sunday, 28 June 2015 at 01:02:02 UTC, Charles Hixson wrote: I'm planning an application where a series of threads each ...gn. Does anyone have a better idea? (The rough estimate of the number of Tids is six, but that's likely to

std.concurrent Tid vector initialization problem

2015-06-27 Thread Charles Hixson via Digitalmars-d-learn
I'm planning an application where a series of threads each need to be aware of the Tids of all the others. The number won't be known at compile time, but that doesn't seem to change the design. All I've been able to come up with is a pair of loops, one to spawn the threads, and collect their

Re: How to simulate a new type

2015-05-15 Thread Charles Hixson via Digitalmars-d-learn
On 05/14/2015 06:38 PM, Adam D. Ruppe via Digitalmars-d-learn wrote: On Friday, 15 May 2015 at 01:03:32 UTC, Charles Hixson wrote: Yes, that looks as if it would do the job, but what are its advantages over a simple struct? None really, except perhaps automatic forwarding of operators which

How to simulate a new type

2015-05-14 Thread Charles Hixson via Digitalmars-d-learn
What are the downsides to simulating a new type with a struct. What I have in mind is something along the lines of: struct myType { uint64_t value; } The goal of this type is to prevent accidental conversions from myType into ints, uint64_ts, etc.

Re: How to simulate a new type

2015-05-14 Thread Charles Hixson via Digitalmars-d-learn
On 05/14/2015 01:42 PM, Laeeth Isharc via Digitalmars-d-learn wrote: On Thursday, 14 May 2015 at 18:42:56 UTC, Charles Hixson wrote: What are the downsides to simulating a new type with a struct. What I have in mind is something along the lines of: struct myType { uint64_t value; } The

Re: Efficiently passing structs

2015-05-06 Thread Charles Hixson via Digitalmars-d-learn
On 05/05/2015 11:49 AM, Ali Çehreli via Digitalmars-d-learn wrote: On 05/05/2015 07:14 AM, bitwise wrote: I don't see how someone could arrive at the above solution without showing up here and asking first. It was the same with me. :) Then I wrote a short section about it:

Re: Accessing a field of a containing class from within a nested class

2015-04-01 Thread Charles Hixson via Digitalmars-d-learn
!hasIndirections!(T). I'm not planning a truly general BTree. In my test version the Key is a ulong and the Data is a struct containing only ulongs and ints.) On 04/01/2015 03:03 PM, Ali Çehreli via Digitalmars-d-learn wrote: On 04/01/2015 11:25 AM, Charles Hixson via Digitalmars-d-learn wrote

Accessing a field of a containing class from within a nested class

2015-04-01 Thread Charles Hixson via Digitalmars-d-learn
The class Node is contained within the struct BTree. The field btFile is contained within the struct BTree. The statement is within a function within the Node class. I've tried many variations, here are a few: btFile.write(self.nodeId, cast(void*)(self)); results in: need 'this' for 'btFile'

Re: Accessing a field of a containing class from within a nested class

2015-04-01 Thread Charles Hixson via Digitalmars-d-learn
On 04/01/2015 11:39 AM, anonymous via Digitalmars-d-learn wrote: On Wednesday, 1 April 2015 at 18:26:49 UTC, Charles Hixson wrote: Perhaps BTree needs to be a class? yes Thanks. Sigh. I was hoping to preserve the determinate closing that one gets with a struct.

Re: buffer to struct type conversion...TArrayStream?

2015-03-19 Thread Charles Hixson via Digitalmars-d-learn
On 03/19/2015 12:05 PM, via Digitalmars-d-learn wrote: On Thursday, 19 March 2015 at 18:42:03 UTC, Marc Schütz wrote: 3) Using std.bitmap.peek(), which also supports conversion between big- and little-endian: import std.bitmap; n.self = buf.peek!(Node.Node_, Endian.bigEndian); (The

buffer to struct type conversion...TArrayStream?

2015-03-19 Thread Charles Hixson via Digitalmars-d-learn
I've read a chunk of data into a buffer and want to convert it into a struct. The reading routine is in a class that doesn't know about the struct, but the size should be exactly the same. (I.e., I want to use the converse procedure to write it.) Is there a better way to do this than using

Re: buffer to struct type conversion...TArrayStream?

2015-03-19 Thread Charles Hixson via Digitalmars-d-learn
On 03/19/2015 11:18 AM, ketmar via Digitalmars-d-learn wrote: On Thu, 19 Mar 2015 10:47:05 -0700, Charles Hixson via Digitalmars-d-learn wrote: turn it 90 degrees. ;-) auto cvt = cast(Node_*)buf.ptr; n = cvt[0]; Whee! Thanks, I don't think I *ever* would have thought of that. I got

How to test for type without refs?

2015-03-17 Thread Charles Hixson via Digitalmars-d-learn
I thought that in: T* user(T)() {static assert (T.sizeof bfHdr.user_.length); static assert (__traits(isPOD, T) ); returncast(T*) bfHdr.user_.ptr; } the line: static assert (__traits(isPOD, T) ); would test for there not being any embedded refs, pointers,

Re: How to test for type without refs?

2015-03-17 Thread Charles Hixson via Digitalmars-d-learn
On 03/17/2015 07:27 AM, anonymous via Digitalmars-d-learn wrote: On Tuesday, 17 March 2015 at 14:06:19 UTC, Charles Hixson wrote: I thought that in: T* user(T)() {static assert (T.sizeof bfHdr.user_.length); static assert (__traits(isPOD, T) ); return

Re: struct / cast / ? design problem

2015-03-16 Thread Charles Hixson via Digitalmars-d-learn
On 03/15/2015 04:51 PM, ketmar via Digitalmars-d-learn wrote: On Sun, 15 Mar 2015 16:34:14 -0700, Charles Hixson via Digitalmars-d-learn wrote: if you know the exact layouts of `spare`, you can use union for that: struct S { // ... union { ulong[61] spare; struct { int vala

Re: struct / cast / ? design problem

2015-03-16 Thread Charles Hixson via Digitalmars-d-learn
On 03/16/2015 09:16 AM, Charles Hixson via Digitalmars-d-learn wrote: On 03/15/2015 04:51 PM, ketmar via Digitalmars-d-learn wrote: On Sun, 15 Mar 2015 16:34:14 -0700, Charles Hixson via Digitalmars-d-learn wrote: if you know the exact layouts of `spare`, you can use union for that: struct

Re: struct / cast / ? design problem

2015-03-16 Thread Charles Hixson via Digitalmars-d-learn
On 03/16/2015 01:24 PM, via Digitalmars-d-learn wrote: The problem in your example is that your making a copy of the returned data. Of course any changes to that copy won't affect the original. You need to return a pointer to it (`ref` won't do if you want to store it in a local variable,

  1   2   >