Re: Datetime format?

2024-01-20 Thread zoujiaqing via Digitalmars-d-learn
mars-d- learn wrote: > > ```D > > import std.datetime : Clock, format; > > import std.stdio : writeln; > > > > void main() > > { > > auto currentTime = Clock.currTime; > > > > auto formattedTime = currentTime.format(&quo

Re: Datetime format?

2024-01-18 Thread H. S. Teoh via Digitalmars-d-learn
> import std.datetime : Clock, format; > > > import std.stdio : writeln; > > > > > > void main() > > > { > > > auto currentTime = Clock.currTime; > > > > > > auto formattedTime = currentTime.format("%Y-%m-%d %H:%M:%

Re: Datetime format?

2024-01-18 Thread Jonathan M Davis via Digitalmars-d-learn
t;> ```D > >> import std.datetime : Clock, format; > >> import std.stdio : writeln; > >> > >> void main() > >> { > >> > >> auto currentTime = Clock.currTime; > >> > >> auto format

Re: Datetime format?

2024-01-18 Thread zoujiaqing via Digitalmars-d-learn
On Thursday, 18 January 2024 at 23:26:42 UTC, zoujiaqing wrote: ```D import std.datetime : Clock, format; import std.stdio : writeln; void main() { auto currentTime = Clock.currTime; auto formattedTime = currentTime.format("%Y-%m-%d %H:%M:%S"); writeln("

Re: Datetime format?

2024-01-18 Thread zoujiaqing via Digitalmars-d-learn
On Thursday, 18 January 2024 at 23:43:13 UTC, Jonathan M Davis wrote: On Thursday, January 18, 2024 4:26:42 PM MST zoujiaqing via Digitalmars-d- learn wrote: ```D import std.datetime : Clock, format; import std.stdio : writeln; void main() { auto currentTime = Clock.currTime; auto

Re: Datetime format?

2024-01-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 18, 2024 4:26:42 PM MST zoujiaqing via Digitalmars-d- learn wrote: > ```D > import std.datetime : Clock, format; > import std.stdio : writeln; > > void main() > { > auto currentTime = Clock.currTime; > > auto formattedTime = currentTim

Datetime format?

2024-01-18 Thread zoujiaqing via Digitalmars-d-learn
```D import std.datetime : Clock, format; import std.stdio : writeln; void main() { auto currentTime = Clock.currTime; auto formattedTime = currentTime.format("%Y-%m-%d %H:%M:%S"); writeln("Formatted Time: ", formattedTime); } ```

Re: assert/static assert message format difference

2023-06-13 Thread Basile B. via Digitalmars-d-learn
.. in that case it's more like a format %s, that takes another path.

assert/static assert message format difference

2023-06-13 Thread DLearner via Digitalmars-d-learn
Only a small thing, but is it intended that: ``` void main() { // static assert (false, "Static Assert triggered"); assert(false, "Assert triggered"); } ``` produces ``` core.exception.AssertError@staticassertex01.d(4): Assert triggered ``` but removing the // produces ```

Re: does the format of coverage files have a name?

2022-07-28 Thread Paul Backus via Digitalmars-d-learn
my editor already has syntax highlighting for it. I think it's a bespoke format with no official name. The closest thing to a spec is this page: https://dlang.org/articles/code_coverage.html

does the format of coverage files have a name?

2022-07-25 Thread Moth via Digitalmars-d-learn
or was the .lst extension chosen arbitrarily? my text editor [notepad++] thinks it's COBOL for some reason but that's obviously not correct, so i'm wondering if it has an official spec or anything. knowing the name of it would help - maybe my editor already has syntax highlighting for it.

Re: dynamic format specifier possible?

2022-01-23 Thread forkit via Digitalmars-d-learn
On Sunday, 23 January 2022 at 22:08:28 UTC, Ali Çehreli wrote: You use an asterisk and provide the width as an argument. This one uses the length of the name of the program: import std; void main(string[] args) { int val = 999000; writefln("[%*s]", args.front.length, val); // [

Re: dynamic format specifier possible?

2022-01-23 Thread Ali Çehreli via Digitalmars-d-learn
On 1/23/22 13:59, forkit wrote: I would like to calculate the width of the format specifier dynamically, at runtime. You use an asterisk and provide the width as an argument. This one uses the length of the name of the program: import std; void main(string[] args) { int val = 999000

dynamic format specifier possible?

2022-01-23 Thread forkit via Digitalmars-d-learn
I would like to calculate the width of the format specifier dynamically, at runtime. e.g int WIDTH = something.length; then my format specifier would be: %WIDTHs instead of %9s // --- module test; import std; void main() { int val = 999000; writefln("[%9s]", val); // [ 999000] } // ---

Re: Dub says that there is an invalid semVer format, but I don't see how.

2021-11-20 Thread Ruby The Roobster via Digitalmars-d-learn
On Saturday, 20 November 2021 at 01:01:05 UTC, rikki cattermole wrote: Don't use ~> for branches. ... Thank you very much. I edited the dub.json, and that fixed the problem(anyways, there is no longer a "testing" branch, so that would have also been an issue.)

Re: Dub says that there is an invalid semVer format, but I don't see how.

2021-11-19 Thread rikki cattermole via Digitalmars-d-learn
Don't use ~> for branches. alpha@DESKTOP-RB97SA4 /tmp/dutils $ dub build Invalid SemVer format: stable.0.0 alpha@DESKTOP-RB97SA4 /tmp/dutils $ nano dub.json alpha@DESKTOP-RB97SA4 /tmp/dutils $ dub build Performing "debug" build using C:\Tools\D\dmd_2.097.2\windows\bin\dmd.e

Re: Dub says that there is an invalid semVer format, but I don't see how.

2021-11-19 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 12 November 2021 at 21:22:32 UTC, Ruby The Roobster wrote: On Thursday, 11 November 2021 at 01:57:10 UTC, rikki cattermole wrote: On 11/11/2021 2:13 PM, Ruby The Roobster wrote: Branch ~master: Invalid SemVer format: testing.0.0 Branch ~testing: Invalid SemVer format: testing.0.0

Re: Dub says that there is an invalid semVer format, but I don't see how.

2021-11-12 Thread Ruby The Roobster via Digitalmars-d-learn
On Thursday, 11 November 2021 at 01:57:10 UTC, rikki cattermole wrote: On 11/11/2021 2:13 PM, Ruby The Roobster wrote: Branch ~master: Invalid SemVer format: testing.0.0 Branch ~testing: Invalid SemVer format: testing.0.0 Version 0.1.2: Invalid SemVer format: testing.0.0 testing is a branch

Re: Dub says that there is an invalid semVer format, but I don't see how.

2021-11-10 Thread rikki cattermole via Digitalmars-d-learn
On 11/11/2021 2:13 PM, Ruby The Roobster wrote: Branch ~master: Invalid SemVer format: testing.0.0 Branch ~testing: Invalid SemVer format: testing.0.0 Version 0.1.2: Invalid SemVer format: testing.0.0 testing is a branch. You are using ~>testing for it. To use a branch in the SEM

Dub says that there is an invalid semVer format, but I don't see how.

2021-11-10 Thread Ruby The Roobster via Digitalmars-d-learn
# Dub says that there is an invalid semVer format, but I don't see how. [Relevant Package:](https://code.dlang.org/packages/dutils) Recently, I added a new tag: v0.1.2 to the github repo, as well as v0.1.2-rc.1(this was later removed.) Now whenever updating the package, dub gives me

Re: writef, compile-checked format, pointer

2021-08-10 Thread Ali Çehreli via Digitalmars-d-learn
On 8/9/21 10:03 PM, nov wrote: > i dreamed that programming will be less-error with compile checking format. I still think so because many errors that can be caught at compile time are moved to run time in non-statically-typed languages. > but reality disappoint :( > message

Re: writef, compile-checked format, pointer

2021-08-10 Thread Tejas via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 05:03:12 UTC, nov wrote: every time i try to use templates, i have problems :( That is why C++ introduced concepts. Wonder when D will be getting them :(

Re: writef, compile-checked format, pointer

2021-08-09 Thread nov via Digitalmars-d-learn
n contains something like "init" or "cast(int*)mytype" i dreamed that programming will be less-error with compile checking format. but reality disappoint :( message for every error in compile-checked format occupy whole screen :( every time i try to use templates, i have problems :(

Re: writef, compile-checked format, pointer

2021-08-09 Thread Ali Çehreli via Digitalmars-d-learn
On 8/9/21 3:46 PM, Adam D Ruppe wrote: > The compile time checker [...] implementation is really really > slow and pretty bloated in codegen too. > > My personal policy is to never use it. My personal policy is to kindly ask you to fix it! :p Ali

Re: writef, compile-checked format, pointer

2021-08-09 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 9 August 2021 at 22:30:43 UTC, Ali Çehreli wrote: I don't know the reason but I suspect a bug in the compile-time checker that involves .init values for arguments. The compile time checker is pretty bad tbh, it just tries to ctfe execute the given string and sees if it throws.

Re: writef, compile-checked format, pointer

2021-08-09 Thread Ali Çehreli via Digitalmars-d-learn
On 8/9/21 3:01 PM, Patrick Schluter wrote: > On Monday, 9 August 2021 at 19:38:28 UTC, novice2 wrote: >> format!"fmt"() and writef!"fmt"() templates >> with compile-time checked format string >> not accept %X for pointers, >> >> but forma

Re: writef, compile-checked format, pointer

2021-08-09 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 9 August 2021 at 22:01:18 UTC, Patrick Schluter wrote: On Monday, 9 August 2021 at 19:38:28 UTC, novice2 wrote: format!"fmt"() and writef!"fmt"() templates with compile-time checked format string not accept %X for pointers, but format() and writef() accept it

Re: writef, compile-checked format, pointer

2021-08-09 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 9 August 2021 at 19:38:28 UTC, novice2 wrote: format!"fmt"() and writef!"fmt"() templates with compile-time checked format string not accept %X for pointers, but format() and writef() accept it https://run.dlang.io/is/aQ05Ux ``` void main() { import std.stdi

writef, compile-checked format, pointer

2021-08-09 Thread novice2 via Digitalmars-d-learn
format!"fmt"() and writef!"fmt"() templates with compile-time checked format string not accept %X for pointers, but format() and writef() accept it https://run.dlang.io/is/aQ05Ux ``` void main() { import std.stdio: writefln; int x; writefln("%X", ); /

Re: Format

2021-05-21 Thread cc via Digitalmars-d-learn
On Saturday, 22 May 2021 at 03:14:35 UTC, cc wrote: Oops, disregard this. I had an error in my imports. It does in fact work in @safe. I should add as an aside then that there is an issue of errors from the body of a toString template not being displayed, and instead the template being

Re: Format

2021-05-21 Thread cc via Digitalmars-d-learn
On Saturday, 22 May 2021 at 03:07:10 UTC, cc wrote: Ahh, in that case it would appear formattedWrite isn't @safe at all. Looks like you have to stick with put()? ```d @safe void toString(W)(ref W writer) if (isOutputRange!(W, char)) { //writer.formattedWrite!("FOO:%s", x); // fails

Re: Format

2021-05-21 Thread cc via Digitalmars-d-learn
On Friday, 21 May 2021 at 16:53:48 UTC, drug wrote: 21.05.2021 18:28, cc пишет: On Friday, 21 May 2021 at 14:19:03 UTC, newbie wrote: Thank you, and formatValue? formattedWrite should handle this. ```d @safe struct Foo { int x = 3; void toString(W)(ref W writer) if

Re: Format

2021-05-21 Thread cc via Digitalmars-d-learn
On Friday, 21 May 2021 at 14:19:03 UTC, newbie wrote: Thank you, and formatValue? formattedWrite should handle this. ```d @safe struct Foo { int x = 3; void toString(W)(ref W writer) if (isOutputRange!(W, char)) { writer.formattedWrite("Foo(%s)", x); }

Re: Format

2021-05-21 Thread newbie via Digitalmars-d-learn
On Friday, 21 May 2021 at 13:59:13 UTC, drug wrote: 21.05.2021 16:45, newbie пишет: I am following https://wiki.dlang.org/Defining_custom_print_format_specifiers, why sink and formatValue are not @safe? What are the best practice for toString in safe code? Thank you sink is obsolete now, use

Re: Format

2021-05-21 Thread drug via Digitalmars-d-learn
21.05.2021 16:45, newbie пишет: I am following https://wiki.dlang.org/Defining_custom_print_format_specifiers, why sink and formatValue are not @safe? What are the best practice for toString in safe code? Thank you sink is obsolete now, use W(riter) ```D import std.range : isOutputRange;

Format

2021-05-21 Thread newbie via Digitalmars-d-learn
I am following https://wiki.dlang.org/Defining_custom_print_format_specifiers, why sink and formatValue are not @safe? What are the best practice for toString in safe code? Thank you

Re: Can I rely on format returned by fullyQualifiedName?

2021-04-24 Thread Jack via Digitalmars-d-learn
On Saturday, 24 April 2021 at 04:09:15 UTC, Mike Parker wrote: On Saturday, 24 April 2021 at 03:40:20 UTC, Jack wrote: Can I rely on this format from fullyQualifiedName? for example, let's say I do: ```d enum s = fullyQualifiedName!f.split; ``` where f is a function member of a class. Can I

Re: Can I rely on format returned by fullyQualifiedName?

2021-04-23 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 24 April 2021 at 03:40:20 UTC, Jack wrote: Can I rely on this format from fullyQualifiedName? for example, let's say I do: ```d enum s = fullyQualifiedName!f.split; ``` where f is a function member of a class. Can I realy that s[0] is the module name, s[1] is the class name

Can I rely on format returned by fullyQualifiedName?

2021-04-23 Thread Jack via Digitalmars-d-learn
Can I rely on this format from fullyQualifiedName? for example, let's say I do: ```d enum s = fullyQualifiedName!f.split; ``` where f is a function member of a class. Can I realy that s[0] is the module name, s[1] is the class name and s[2] the functio name? is this standard or can

Re: Is this bug ? format %(%)

2021-04-07 Thread Meta via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 17:31:09 UTC, Paul Backus wrote: On Wednesday, 7 April 2021 at 17:04:56 UTC, novice2 wrote: On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote: So, you should change your code to writefln("%-(%s, %)", s); sorry i dont read docs so carefully

Re: Is this bug ? format %(%)

2021-04-07 Thread Berni44 via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 17:31:09 UTC, Paul Backus wrote: It's not your fault--this is a pretty obscure feature, and it's not documented very well. Even after you've found the correct page in the documentation (the page for `formattedWrite` [1]), you have to scroll down past multiple

Re: Is this bug ? format %(%)

2021-04-07 Thread Ali Çehreli via Digitalmars-d-learn
On 4/7/21 10:04 AM, novice2 wrote: On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote: So, you should change your code to     writefln("%-(%s, %)", s); sorry i dont read docs so carefully thanks For the sake of completeness, I mention this feature in a couple of other places:

Re: Is this bug ? format %(%)

2021-04-07 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 17:04:56 UTC, novice2 wrote: On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote: So, you should change your code to writefln("%-(%s, %)", s); sorry i dont read docs so carefully thanks It's not your fault--this is a pretty obscure feature, and

Re: Is this bug ? format %(%)

2021-04-07 Thread novice2 via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote: So, you should change your code to writefln("%-(%s, %)", s); sorry i dont read docs so carefully thanks

Re: Is this bug ? format %(%)

2021-04-07 Thread Paul Backus via Digitalmars-d-learn
format specifier, strings and characters are escaped automatically. To avoid this behavior, add '-' flag to "%(". So, you should change your code to writefln("%-(%s, %)", s);

Is this bug ? format %(%)

2021-04-07 Thread novice3 via Digitalmars-d-learn
https://run.dlang.io/is/p4NVp8 ```d void main() { import std.stdio: writefln; string[] s = ["a", "b", "c"]; writefln("%(%s, %)", s); } ``` output ```d "a", "b", "c" ``` expected ```d a, b, c ``` there is extra quotes, wich not present in firmat specifier. is this bug, or i should

Re: How to open a compressed file in gz format ?

2021-03-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/14/21 9:36 PM, sharkloc wrote: I want to read the content(file.gz) line by line,the following code is not friendly to large files of hundreds of Gb, and the memory overhead is also very large. import std.stdio; import std.process; import std.string; void main(string[] args){

Re: How to open a compressed file in gz format ?

2021-03-16 Thread frame via Digitalmars-d-learn
On Monday, 15 March 2021 at 01:36:08 UTC, sharkloc wrote: I want to read the content(file.gz) line by line,the following code is not friendly to large files of hundreds of Gb, and the memory overhead is also very large. You can use the internal zlib instead of a shell. This example is using

How to open a compressed file in gz format ?

2021-03-14 Thread sharkloc via Digitalmars-d-learn
I want to read the content(file.gz) line by line,the following code is not friendly to large files of hundreds of Gb, and the memory overhead is also very large. import std.stdio; import std.process; import std.string; void main(string[] args){ string fileName = args[1];

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-15 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 15 November 2020 at 03:14:07 UTC, Marcone wrote: I want to convert seconds to hour, minut and second. Do you want to convert a *duration* into hours/minutes/seconds, or format a UNIX *timestamp* to hours/minutes/seconds? These are conceptually two different things

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn
On Sunday, 15 November 2020 at 03:15:29 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote: On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime()

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn
On Sunday, 15 November 2020 at 03:15:29 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote: On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime()

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote: On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime() writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn
On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime() writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some like this in D? auto mytime = Clock.currTime;

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn
On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime() writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some like this in D? auto mytime = Clock.currTime;

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime() writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some like this in D? auto mytime = Clock.currTime; writefln("%02dh:%02dm:%02ds", mytime.hour, mytime.minute, mytime.second);

How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn
auto mytime = Clock.currTime().toUnixTime() writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some like this in D?

Re: Range format specifiers in other languages?

2020-10-12 Thread H. S. Teoh via Digitalmars-d-learn
% before ( needed in the > > > format string? > > > > The %( ... %) stuff is expanded and repeated for each element inside > > the given array. > > Thanks, it seems there are some pretty powerful formatting options: > > https://dlang.org/phobos/std_format.html Indeed. %

Re: Range format specifiers in other languages?

2020-10-11 Thread Imperatorn via Digitalmars-d-learn
On Monday, 12 October 2020 at 00:59:33 UTC, Adam D. Ruppe wrote: On Monday, 12 October 2020 at 00:46:37 UTC, Imperatorn wrote: To people trying to learn, why is that % before ( needed in the format string? The %( ... %) stuff is expanded and repeated for each element inside the given array

Re: Range format specifiers in other languages?

2020-10-11 Thread Ali Çehreli via Digitalmars-d-learn
On 10/11/20 5:44 PM, Max Haughton wrote: > Possibly worth showing off (especially given that some people at first > don't even know the templated format string exists) This feature is already among my slides for an upcoming conference. ;) Ali

Re: Range format specifiers in other languages?

2020-10-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 12 October 2020 at 00:46:37 UTC, Imperatorn wrote: To people trying to learn, why is that % before ( needed in the format string? The %( ... %) stuff is expanded and repeated for each element inside the given array.

Re: Range format specifiers in other languages?

2020-10-11 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 11 October 2020 at 23:57:31 UTC, Ali Çehreli wrote: I find D's %( and %) range format specifiers very useful: import std.stdio; import std.range; void main() { 5.iota.writefln!"%(%s, %)"; // Prints 0, 1, 2, 3, 4 } Are there similar features in other languages? Than

Re: Range format specifiers in other languages?

2020-10-11 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 11 October 2020 at 23:57:31 UTC, Ali Çehreli wrote: I find D's %( and %) range format specifiers very useful: import std.stdio; import std.range; void main() { 5.iota.writefln!"%(%s, %)"; // Prints 0, 1, 2, 3, 4 } Are there similar features in other languages? Than

Range format specifiers in other languages?

2020-10-11 Thread Ali Çehreli via Digitalmars-d-learn
I find D's %( and %) range format specifiers very useful: import std.stdio; import std.range; void main() { 5.iota.writefln!"%(%s, %)"; // Prints 0, 1, 2, 3, 4 } Are there similar features in other languages? Thank you, Ali

Re: Link Time Optimization Bitcode File Format

2020-10-06 Thread kinke via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 16:46:28 UTC, Severin Teona wrote: Also, when I try to link the druntime with the application I want to write on the microcontroller, there are some link errors due to the file format. This happens when you link manually, not through LDC. When running LDC

Re: Link Time Optimization Bitcode File Format

2020-10-06 Thread IGotD- via Digitalmars-d-learn
was to use Link Time Optimization (LTO) to reduce the size. The problem now is the fact that when I compile the druntime with -flto=full or -flto=thin (as arguments for LDC2), the resulted object files (and also a big part of the runtime as it is a static library) have a different file format

Link Time Optimization Bitcode File Format

2020-10-06 Thread Severin Teona via Digitalmars-d-learn
. The problem now is the fact that when I compile the druntime with -flto=full or -flto=thin (as arguments for LDC2), the resulted object files (and also a big part of the runtime as it is a static library) have a different file format - LLVM IR bitcode - than I need, which is ELF 32-bit. Also, when

Re: assert format of a string before a mixin

2020-09-27 Thread ddcovery via Digitalmars-d-learn
On Sunday, 27 September 2020 at 21:41:25 UTC, Adam D. Ruppe wrote: On Sunday, 27 September 2020 at 21:38:43 UTC, ddcovery wrote: i.e. checking this Regex expression `^[a-zA-Z_]*[a-zA-Z0-9_]*[a-zA-Z][a-zA-Z0-9_]*$` Is there any way to check a regular expression at compile time? Not really

Re: assert format of a string before a mixin

2020-09-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 September 2020 at 21:38:43 UTC, ddcovery wrote: i.e. checking this Regex expression `^[a-zA-Z_]*[a-zA-Z0-9_]*[a-zA-Z][a-zA-Z0-9_]*$` Is there any way to check a regular expression at compile time? Not really and I'd actually suggest not trying because even if it did work,

assert format of a string before a mixin

2020-09-27 Thread ddcovery via Digitalmars-d-learn
I have a "variation" of "unaryFun" that I name "unaryProp" that, basically, doesn't require to specify "a." at the beginning of the expression. template unaryProp(alias propName) { static assert(is(typeof(propName) : string), "Sorry, propName must be an string"); auto

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread Ecstatic Coder via Digitalmars-d-learn
need to accurately store the file modification SysTime in binary format, so that I can later load this SysTime from the snapshot file to compare it with the current file modification SysTime. Having unfortunately not understood how to do this from the SysTime documentation, in despair, I've

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 7:44 AM, Ecstatic Coder wrote: On Tuesday, 21 July 2020 at 11:01:20 UTC, drug wrote: On 7/20/20 10:04 PM, Ecstatic Coder wrote: I'm currently implementing a small open source backup tool (dub), and therefore I need to accurately store the file modification SysTime in binary format

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread drug via Digitalmars-d-learn
On 7/21/20 2:44 PM, Ecstatic Coder wrote: Ah thanks for telling me :) The loaded byte array in the union type was indeed the same as the saved one, so I immediately thought it was crashing because of some hidden pointer for timezone or something which was then pointing to garbage at

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread Ecstatic Coder via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 11:01:20 UTC, drug wrote: On 7/20/20 10:04 PM, Ecstatic Coder wrote: I'm currently implementing a small open source backup tool (dub), and therefore I need to accurately store the file modification SysTime in binary format, so that I can later load this SysTime

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread drug via Digitalmars-d-learn
On 7/20/20 10:04 PM, Ecstatic Coder wrote: I'm currently implementing a small open source backup tool (dub), and therefore I need to accurately store the file modification SysTime in binary format, so that I can later load this SysTime from the snapshot file to compare it with the current file

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread Ecstatic Coder via Digitalmars-d-learn
As my question obviously didn't interest any expert, I took advantage of my lunch break to do some more research ;) Maybe I'm wrong, but to my knowledge, there is no function to get the number of hectonanoseconds since January 1, 1970. Fortunately I can get the number of seconds since the

Accurately serializing and deserializing a SysTime in binary format

2020-07-20 Thread Ecstatic Coder via Digitalmars-d-learn
I'm currently implementing a small open source backup tool (dub), and therefore I need to accurately store the file modification SysTime in binary format, so that I can later load this SysTime from the snapshot file to compare it with the current file modification SysTime. Having

Re: How to compile to .bin/.iso format

2020-06-17 Thread FeepingCreature via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 12:39:11 UTC, FeepingCreature wrote: On Wednesday, 17 June 2020 at 12:30:24 UTC, Quantium wrote: Hi all! I have a programm in D (The simplest OS), which should be compiled into .bin or .iso format to be possible to run it on VirtualBox. How can I compile

Re: How to compile to .bin/.iso format

2020-06-17 Thread FeepingCreature via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 12:30:24 UTC, Quantium wrote: Hi all! I have a programm in D (The simplest OS), which should be compiled into .bin or .iso format to be possible to run it on VirtualBox. How can I compile it to .bin / .iso format and which compiler should I use? Try this page

How to compile to .bin/.iso format

2020-06-17 Thread Quantium via Digitalmars-d-learn
Hi all! I have a programm in D (The simplest OS), which should be compiled into .bin or .iso format to be possible to run it on VirtualBox. How can I compile it to .bin / .iso format and which compiler should I use?

Re: Easy way to format int in pragma msg ?

2020-05-14 Thread wjoe via Digitalmars-d-learn
. for simple hex/binary/etc printing use import std.conv; pragma(msg, i.to!string(16)); where you can replace 16 with your target base. You can also use format as in the previous reply if you want more formatting control That's great. Thanks for the fast reply. To both of you :)

Re: Easy way to format int in pragma msg ?

2020-05-14 Thread WebFreak001 via Digitalmars-d-learn
; pragma(msg, i.to!string(16)); where you can replace 16 with your target base. You can also use format as in the previous reply if you want more formatting control

Re: Easy way to format int in pragma msg ?

2020-05-14 Thread John Chapman via Digitalmars-d-learn
On Thursday, 14 May 2020 at 09:49:15 UTC, wjoe wrote: Is there an easy way to print an int in hexadecimal, octal or binary representation ? The documentation on pragma(msg, ...) and a quick web search didn't provide an answer. import std.string; pragma(msg, format("%x", 10));

Easy way to format int in pragma msg ?

2020-05-14 Thread wjoe via Digitalmars-d-learn
Is there an easy way to print an int in hexadecimal, octal or binary representation ? The documentation on pragma(msg, ...) and a quick web search didn't provide an answer.

Re: format with floating points GC allocating in DMD 2.090

2020-02-07 Thread Rainer Schuetze via Digitalmars-d-learn
On 31/01/2020 09:45, bauss wrote: > On Friday, 31 January 2020 at 07:20:17 UTC, cc wrote: >> char[4096] buf; >> writeln(GC.stats.usedSize); >> foreach (i; 0 .. 10) { >>     sformat(buf, "%f", 1.234f); >>     writeln(GC.stats.usedSize); >> } >> >> Output with DMD32 D

Re: format with floating points GC allocating in DMD 2.090

2020-01-31 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 31 January 2020 at 08:45:55 UTC, bauss wrote: On Friday, 31 January 2020 at 07:20:17 UTC, cc wrote: char[4096] buf; writeln(GC.stats.usedSize); foreach (i; 0 .. 10) { sformat(buf, "%f", 1.234f); writeln(GC.stats.usedSize);

Re: format with floating points GC allocating in DMD 2.090

2020-01-31 Thread bauss via Digitalmars-d-learn
On Friday, 31 January 2020 at 07:20:17 UTC, cc wrote: char[4096] buf; writeln(GC.stats.usedSize); foreach (i; 0 .. 10) { sformat(buf, "%f", 1.234f); writeln(GC.stats.usedSize); } Output with DMD32 D Compiler v2.089.1-dirty (Win10

format with floating points GC allocating in DMD 2.090

2020-01-30 Thread cc via Digitalmars-d-learn
char[4096] buf; writeln(GC.stats.usedSize); foreach (i; 0 .. 10) { sformat(buf, "%f", 1.234f); writeln(GC.stats.usedSize); } Output with DMD32 D Compiler v2.089.1-dirty (Win10 x64): 16 16 16 ... Output with DMD32 D Compiler

Re: Custom separator in array format

2020-01-28 Thread Malte via Digitalmars-d-learn
On Tuesday, 28 January 2020 at 08:54:16 UTC, Simen Kjærås wrote: import std.stdio : writefln; import std.format : format; import std.algorithm : map; auto vec = [1000, 2000, 3000]; writefln("%-(%s\t%)", vec.map!(e => format!"%,2?d"('_', e))); Tha

Re: Custom separator in array format

2020-01-28 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 28 January 2020 at 07:36:25 UTC, Malte wrote: I want to format an array using the %(...%) syntax. How can I change the separator? I tried to use ? and add it as additional parameter, but that doesn't seem to work on arrays: import std; void main() { writeln("This

Custom separator in array format

2020-01-27 Thread Malte via Digitalmars-d-learn
I want to format an array using the %(...%) syntax. How can I change the separator? I tried to use ? and add it as additional parameter, but that doesn't seem to work on arrays: import std; void main() { writeln("This works:"); writefln("%,2?d", '_', 2000); //

Re: import/format tools?

2020-01-18 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 18 January 2020 at 09:33:34 UTC, mark wrote: Is there a tool that will sort imports (e.g., as per the style guide), and that will also add the specific names used? D-Scanner[1] will warn you about non sorted imports You need to set imports_sortedness="enabled" on your

import/format tools?

2020-01-18 Thread mark via Digitalmars-d-learn
Is there a tool that will sort imports (e.g., as per the style guide), and that will also add the specific names used? Also, is there a D source formatting tool (ideally with options to set a max line length and choice of braces style)? Is there any runtime (or compiletime) cost to just

Re: std.format range with compound format specifiers?

2019-11-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/19/19 7:28 PM, Petar Kirov [ZombineDev] wrote: In cases where I have some aggregate data, but I don't feel like writing a custom toString method, I often wrap the data in a Tuple and use its [1] %(inner%) or %(inner%|sep%) format specifiers. Here's an example: import std; void main

Re: std.format range with compound format specifiers?

2019-11-19 Thread Petar via Digitalmars-d-learn
On Tuesday, 19 November 2019 at 21:50:08 UTC, Steven Schveighoffer wrote: I know I can format a range with a format string that contains %(%s, %). And this results in a nice comma separated list for each item. But what about an item that has a not-so-cookie-cutter format? Like for instance

std.format range with compound format specifiers?

2019-11-19 Thread Steven Schveighoffer via Digitalmars-d-learn
I know I can format a range with a format string that contains %(%s, %). And this results in a nice comma separated list for each item. But what about an item that has a not-so-cookie-cutter format? Like for instance a name/value field: struct NV { string name; int value; } If I want

Re: Substitutions with writef() or format()?

2019-07-14 Thread Ron Tarrant via Digitalmars-d-learn
On Sunday, 14 July 2019 at 13:45:38 UTC, Ron Tarrant wrote: 'Morning, all. If these lines: string currency = format("$%,.02f", 11_234_456.99); writeln(currency); Will result in: $11,234,456.99 Why don't these lines: string notCurrency = format("%,", 11_

Substitutions with writef() or format()?

2019-07-14 Thread Ron Tarrant via Digitalmars-d-learn
'Morning, all. If these lines: string currency = format("$%,.02f", 11_234_456.99); writeln(currency); Will result in: $11,234,456.99 Why don't these lines: string notCurrency = format("%,", 11_234_456); writeln(notCurrency); result in: 11,234,456 ???

Re: Orphan format arguments: args[0..1]

2018-12-16 Thread Ali Çehreli via Digitalmars-d-learn
On 12/16/2018 12:00 PM, Steven Schveighoffer wrote: >> Now there is a compilation error: >> >>Orphan format arguments: args[0..1] > > Hm... maybe a runtime error? I didn't think the compiler knows to > complain about this. Sorry, it was a runtime error. (I was

Re: Orphan format arguments: args[0..1]

2018-12-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/15/18 7:34 PM, Ali Çehreli wrote: This one confused me until I decided to talk to a rubber ducky: import std.string; void main() {     auto s = "%s is a good number".format(42); } Fine; it works... Then the string becomes too long and I split it:     auto s = "%s i

  1   2   3   4   >