On Sunday, 3 December 2023 at 13:42:53 UTC, zoujiaqing wrote:
Use botan so easy:
Well, what about:
```D
import std.digest.sha;
import std.stdio;
void main()
{
string appKey =
"1";
appKey.sha256Of.toHexString.writeln;
}
```
Not sur
On Wednesday, 26 April 2023 at 18:24:08 UTC, DLearner wrote:
Consider:
```
struct S1 {
int A;
int B;
int foo() {
return(A+B);
}
}
struct S2 {
int A;
int B;
}
int fnAddS2(S2 X) {
return (X.A + X.B);
}
There are scenarios that won't let you use the second form, e.g.
p
On Thursday, 13 April 2023 at 07:05:10 UTC, Chris Katko wrote:
I'm trying to figure out how to return a reference to something
that may not be a reference type.
```d
@safe:
struct Stats
{
float[string] data;
ref opIndex(string key) return
{
// The `require()` takes care of
On Thursday, 6 April 2023 at 20:23:29 UTC, Jacob Shtokolov wrote:
On Thursday, 6 April 2023 at 00:46:26 UTC, Josh Holtrop wrote:
I am trying to port a small C project to D and am getting a
Ah, just noticed that other people have already responded! Sorry
about that!
BTW, your `&data[0]` C-like
On Thursday, 6 April 2023 at 00:46:26 UTC, Josh Holtrop wrote:
I am trying to port a small C project to D and am getting a
compilation error I don't understand.
It seems like the compiler is just missing some type hints. Try
this:
```d
import std.stdio;
__gshared immutable ubyte[4] data = [
On Tuesday, 28 March 2023 at 05:05:58 UTC, Alexander Zhirov wrote:
`Error: cannot cast expression 'cast(ubyte*)arr' of type
'ubyte*' to 'ubyte[16]'`
Here is the working example:
```d
import std.stdio;
import std.uuid;
void main()
{
ubyte[] arr = [159, 199, 22, 163, 13, 74, 145, 73, 158, 112,
On Sunday, 26 March 2023 at 18:07:03 UTC, ryuukk_ wrote:
What i do not understand is the reasoning behind choosing tls
global by default in D
Because the language maintainers decided that they want to
emphasize the actor model with no default shared state in the
language.
This is quite bene
On Friday, 24 March 2023 at 09:59:47 UTC, Alexander Zhirov wrote:
On Friday, 24 March 2023 at 09:46:26 UTC, Jacob Shtokolov wrote:
BTW, you can also `alias this` your struct value and then use
`std.conv : to` for casting, if you don't need specific
casting rules.
I don't quite understand what
On Friday, 24 March 2023 at 09:39:00 UTC, Jacob Shtokolov wrote:
On Thursday, 23 March 2023 at 13:38:51 UTC, Alexander Zhirov
wrote:
Is it possible to convert such records inside the structure to
the assigned type?
BTW, you can also `alias this` your struct value and then use
`std.conv : to`
On Thursday, 23 March 2023 at 13:38:51 UTC, Alexander Zhirov
wrote:
Is it possible to convert such records inside the structure to
the assigned type?
```d
struct MyVal
{
string value;
// Here it would be possible to use an alias to this, but
it can only be used 1 time
}
auto a = MyVa
On Saturday, 3 December 2022 at 11:08:53 UTC, Vincent wrote:
Unfortunately even TECHNICALLY stream never was a "range"! It's
more like "queue of bytes", where you can never be sure you
even get these bytes.
A stream is exactly a range, a "range of ranges" if more
specifically. All network dev
On Thursday, 24 December 2020 at 10:23:09 UTC, Dmitriy Asondo
wrote:
Hi!
I'm trying to check some js-like features. For example, if I
want to store somewhere in array|tuple a list of pointers to
classes (app services) how may I do that?
Hi, it seems that what you're looking for is Prototype
On Monday, 21 October 2019 at 19:20:04 UTC, Prokop Hapala wrote:
What exactly should I specify to make it link dynamcially and
produce as small binary as possible (without increasing
compilation time) ?
Hi! Sorry, just found your response here. In order to force it to
link dynamically, add th
Hi,
Recently, I was trying to solve some funny coding challenges
(https://www.techgig.com).
The questions were really simple, but I found it interesting
because the website allows to use D.
One of the task was to take a string from STDIN and detect its
type.
There were a few options: Float,
On Wednesday, 23 January 2019 at 17:28:37 UTC, H. S. Teoh wrote:
The best way to do this is to use a string DSL or a delegate as
template argument. For example:
auto result = User.filter!q{ User.name == "John" };
or:
auto result = User.filter!(u => u.name == "John");
I didn
On Thursday, 24 January 2019 at 00:47:37 UTC, Ali Çehreli wrote:
Yeah, that can't work. Remove the bool-returning one and your
code works with the 'alias this' above.
Wow, this is an amazing workaround! I didn't think about it in
that way.
It perfectly solves the issue.
Thank you!
On Wednesday, 23 January 2019 at 15:28:02 UTC, Jonathan M Davis
wrote:
But regardless of the specifics of operator overloading in D, D
does not support overloading _any_ functions on the return type.
Thanks!
Hi,
I'm trying to check whether it's possible to implement Python's
SQLAlchemy-like query syntax in D, but I get stuck a bit.
Here is a simple example of what I want to achieve:
```
auto result = User.filter(User.id == 10);
result = User.filter(User.name == "John");
result = User.filter(User.
On Friday, 4 January 2019 at 14:36:16 UTC, Mike Parker wrote:
v is a run-time value, not available at compile time.
Sorry about that, looks like if I edit the text in the
run.dlang.io editor, the link also gets updated. I was using
"void opAssign(T)(T v)" in the initial example, but it seems
On Friday, 4 January 2019 at 11:45:24 UTC, Jacob Shtokolov wrote:
Here is the simple example:
https://run.dlang.io/gist/1a06dd703bea5548ee72b4713a7ce5f6
Sorry, invalid link.
Here is a new one: https://run.dlang.io/is/QZ5hLV
On Friday, 4 January 2019 at 11:41:59 UTC, Simen Kjærås wrote:
The thing is, compile-time tests like static if and static
assert can only test values that are known at compile-time, and
are for the most part useful only in templates.
Thanks for this answer! That's sad to hear.
But, is there an
On Friday, 4 January 2019 at 10:34:07 UTC, Basile.B wrote:
Show us some code.
Here is the simple example:
https://run.dlang.io/gist/1a06dd703bea5548ee72b4713a7ce5f6
The thing I'm trying to do is to make an experimental port (for
education purposes) of https://github.com/fthomas/refined libra
Hi,
I'd like to implement some compile time constraints for a struct
(though not sure if that's possible).
I already tried to place "static assert" or any kind of static
condition into a body of @property and opAssign(), but every time
it shows the error "variable cannot be read at compile t
On Wednesday, 5 September 2018 at 16:53:42 UTC, NX wrote:
Is there a way to know what kind of context a delegate has
either in compile time or runtime?
Also is there any way to check whether a pointer legitimately
points to an Object instance?
No and no. I was fighting this problem in std.si
On Monday, 27 August 2018 at 14:11:32 UTC, SG wrote:
On Monday, 27 August 2018 at 13:02:28 UTC, rikki cattermole
wrote:
So Nullable in D and C# is basically the same except C#'s has
language support.
Shouldn't it be in the standard library?
I think it's worth it to create a feature request i
On Tuesday, 31 July 2018 at 15:19:19 UTC, Dan Barbarito wrote:
Hi all,
I am starting to write a command line tool.
Hi!
First, Vibe.d will increase your binary size because it contains
a lot of unnecessary things inside it. So instead of using the
entire vibe.d library, you may point dub to
On Wednesday, 25 July 2018 at 09:42:00 UTC, Ivo wrote:
I'm a macOs user and I need to build a application with a GUI.
Not sure if the author of the DLangUI is visiting this forum so
often to be able to answer.
If you won't get an answer in the next few days, I would
recommend to make an iss
On Sunday, 1 July 2018 at 05:20:17 UTC, Anton Fediushin wrote:
Now I tried it and indeed, it's vibe.d's fault. I'm not quite
sure what causes it and if this problem is known, I'll look
into that later and open an issue if it doesn't exist already.
Yes, please do this when you have time. That w
On Friday, 29 June 2018 at 17:40:07 UTC, Anton Fediushin wrote:
So, long story short:
- Usage of Mallocator instead of theAllocator made it a little
bit better
- VibeManualMemoryManagement had no (or little) effect
- Manually calling GC.collect had no (or little) effect
You could try to call
On Saturday, 16 June 2018 at 01:24:04 UTC, crimaniak wrote:
Hi all!
The first try to host application on Heroku provider. The
application is started and starts to listen in 3 seconds on the
port, provided by heroku-buildpack-d. But the server doesn't
detect listening and stops the application
30 matches
Mail list logo