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
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.
On Wednesday, 26 April 2023 at 14:54:40 UTC, max haughton wrote:
https://github.com/dlang/dmd/pull/13776
Wow, didn't know about this PR exists. Thank you for sharing!
On Wednesday, 26 April 2023 at 12:50:32 UTC, bachmeier wrote:
Many other solutions were provided as well, including but not
limited to
- Using shorter names
- Using alias
- Using an IDE with autocomplete
- Using copy and paste
While aliases and shorter names are always good options,
On Tuesday, 25 April 2023 at 20:15:39 UTC, ryuukk_ wrote:
void set_connected()
{
network_connect_state = NetworkConnectState.CONNECTED
}
MySuperLongNameFlag flag = MySuperLongNameFlag.A |
MySuperLongNameFlag.B | MySuperLongNameFlag.C |
MySuperLongNameFlag.D;
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
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 `[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,
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
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
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 =
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
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 Saturday, 30 May 2020 at 20:29:37 UTC, Adam D. Ruppe wrote:
We should make this actually work for everything.
1) Make inferred_attr: NOT apply to template/auto functions.
2) Add inverse attributes for all things. (or tri-state,
true/false/null)
3) Solve the child scope problem somehow
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
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 Monday, 25 February 2019 at 20:31:43 UTC, Paul Backus wrote:
- Pattern matching, including support for structural matching
(★)
What is the main difference between 'match()' in this library and
'visit()' in std.variant?
On Friday, 25 January 2019 at 11:07:48 UTC, Jacob Shtokolov wrote:
This is where the precise GC might play a better role, BTW.
Misspelling: not precise, conservative GC of course.
On Friday, 25 January 2019 at 10:15:15 UTC, Martin Tschierschke
wrote:
( On my wish list at the top: An official D database connector.
(MySql/MariaDB, Postgres, SQlite, MonetDB..) )
What about trying to find and to fund a maintainer for this
purpose?
(Next funding goal Mike Parker?)
I
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
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 =
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
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
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
Hi,
According to the docs: https://dlang.org/spec/memory-safe-d.html
Memory-safe code cannot use certain language features, such as:
Casts that break the type system.
Modification of pointer values.
Taking the address of a local variable or function parameter.
So, modification of
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
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
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
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
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 19:20:30 UTC, FromAnotherPlanet
wrote:
- Interface segregation principal: Essentially breaking the
program up into smaller interfaces. Sometimes only consistent
of one or two methods/properties (can feed into 'S' of SOLID
quite nicely).
- Dependency inversion
On Saturday, 16 June 2018 at 17:46:56 UTC, Jonathan M Davis wrote:
I would point out that in general, doing that with attributes
is rather error-prone, because it's easy for folks reading the
code to miss them, making it unclear that they're in effect,
and because unfortunately most attributes
On Saturday, 16 June 2018 at 18:47:10 UTC, Steven Schveighoffer
wrote:
I would just caution that this does not affect member
functions, only module-level functions. You have to repeat the
@safe: inside any structs or classes as well.
Just tried that and it works very well (throws compilation
On Saturday, 16 June 2018 at 13:57:48 UTC, Bastiaan Veelo wrote:
On Saturday, 16 June 2018 at 13:52:37 UTC, Jacob Shtokolov
wrote:
Is it possible to introduce a new parameter/flag to the
compiler, to force all functions be @safe by default on a
per-module basis?
For example:
```
module
Hi folks,
I know there were a lot of discussions on this topic, and it is
understandable that due to historical reasons the D language is
designed with C/C++ interop in mind, so it means that there is no
@safe by default.
However, I also see a lot of people who want this feature, and I
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
On Tuesday, 12 June 2018 at 15:39:52 UTC, Zoadian wrote:
On Tuesday, 12 June 2018 at 15:21:49 UTC, Jacob Shtokolov wrote:
On Tuesday, 12 June 2018 at 14:33:57 UTC, Steven Schveighoffer
wrote:
[...]
Thank you Steve!
Then I'll try to fire a bug report and propose my own solution
to this
On Tuesday, 12 June 2018 at 14:33:57 UTC, Steven Schveighoffer
wrote:
On 6/12/18 9:04 AM, Jacob Shtokolov wrote:
[...]
I'll respond to say that I don't know a lot of people who use
signals and slots. It's a very old part of Phobos, and I think
a lot of people here aren't familiar with it.
On Thursday, 7 June 2018 at 12:56:55 UTC, Jacob Shtokolov wrote:
Hello,
I'd like to start a discussion about the standard std.signals
library.
[...]
5 days passed and no one answered
Maybe the guys who are contributing to DRuntime could answer: is
that possible to attach GC dispose
Hello,
I'd like to start a discussion about the standard std.signals
library.
Currently it has a strange limitation - you can't pass delegates
that don't belong to an object.
I reviewed the source code an came to conclusion that it can be
easily fixed.
However, the thing that concerns
47 matches
Mail list logo