On Thursday, 17 December 2020 at 14:49:42 UTC, evilrat wrote:
On Tuesday, 15 December 2020 at 16:25:29 UTC, Trustee wrote:
connect a basic vibe-d app to a graphql backend.
umm, what?
Did you mean write graphql backend using vibe.d?
Vibe-d web app -> Vibe-d/GraphQL gateway server (a la Pris
On Thursday, 17 December 2020 at 14:49:42 UTC, evilrat wrote:
On Tuesday, 15 December 2020 at 16:25:29 UTC, Trustee wrote:
connect a basic vibe-d app to a graphql backend.
umm, what?
Did you mean write graphql backend using vibe.d?
Yes. But more so, I want to learn the ins and outs of the
On Thursday, 17 December 2020 at 21:40:09 UTC, Dave P. wrote:
Very cool! Where can I read about what an alias as a template
parameter does?
https://dlang.org/spec/template.html#aliasparameters
https://github.com/PhilippeSigaud/D-templates-tutorial
On Thu, Dec 17, 2020 at 06:57:08PM +, IGotD- via Digitalmars-d-learn wrote:
[...]
> How does this connect to the array with zero elements? According to
> your explanation if I have understood it correctly, capacity is also
> indicating if the pointer has been "borrowed" from another array
> for
On Thursday, 17 December 2020 at 21:10:20 UTC, Q. Schroll wrote:
I don't have an answer, but aliasing non-static fields outside
the struct isn't something one does often. This is probably a
bug.
At least it wasn't just me overlooking something.
If it is a bug, I wonder which part of it is bug
On Thursday, 17 December 2020 at 21:24:40 UTC, FreeSlave wrote:
On Thursday, 17 December 2020 at 19:45:38 UTC, Dave P. wrote:
[...]
Something like that?
import std.stdio;
void print_int(alias n)()
{
writeln(n.stringof~"=", n);
}
void main()
{
int x = 42;
print_int!(x);
prin
On Thursday, 17 December 2020 at 19:45:38 UTC, Dave P. wrote:
In C, you can use a macro to get the source text of an
expression as a string. For example
#include
#define PRINT_INT(x) printf(#x " = %d\n", x)
int main(){
// prints "3 = 3"
PRINT_INT(3);
int x = 4;
// prints "x =
On Thursday, 17 December 2020 at 19:45:38 UTC, Dave P. wrote:
In C, you can use a macro to get the source text of an
expression as a string. For example
#include
#define PRINT_INT(x) printf(#x " = %d\n", x)
int main(){
// prints "3 = 3"
PRINT_INT(3);
int x = 4;
// prints "x =
On Saturday, 12 December 2020 at 01:02:56 UTC, SealabJaster wrote:
Please see this shortened snippet: https://godbolt.org/z/j8f3x5
I've ran into annoyances before when using aliases to member
fields, but something subtle like this was rather annoying to
figure out.
Why does the compiler feel
~~~json.d
void main ()
{
import std.stdio;
import std.json;
string [] json = [
`{
"range": [
{"x": "iks"}
],
"range": "variable"
}`,
`{
"range": "variable",
"range": [
{"x": "iks"}
]
}`
];
foreach (js; json) {
auto jv = parseJSON (js, JSONOptions
In C, you can use a macro to get the source text of an expression
as a string. For example
#include
#define PRINT_INT(x) printf(#x " = %d\n", x)
int main(){
// prints "3 = 3"
PRINT_INT(3);
int x = 4;
// prints "x = 4"
PRINT_INT(x);
#define FOO 5
// prints "FOO = 5"
On 12/17/20 8:48 AM, Ali Çehreli wrote:
> There is also assumeUnique()
I meant assumeSafeAppend().
Ali
On Thursday, 17 December 2020 at 18:42:54 UTC, H. S. Teoh wrote:
Are you sure?
My understanding is that capacity is always set to 0 when you
shrink an array, in order to force reallocation when you append
a new element. The reason is this:
int[] data = [ 1, 2, 3, 4, 5 ];
int
On Thu, Dec 17, 2020 at 06:10:25PM +, IGotD- via Digitalmars-d-learn wrote:
[...]
> b.m_buffer.length 2, b.m_buffer.capacity 31
> b.m_buffer.length 0, b.m_buffer.capacity 0
>
> capacity 0, suggests that the array has been deallocated.
Are you sure?
My understanding is that capacity is always
On Thursday, 17 December 2020 at 17:46:59 UTC, Steven
Schveighoffer wrote:
This isn’t correct. Can you post the code that led you to
believe this?
-Steve
Sure.
import std.algorithm;
import std.typecons;
import std.stdio;
struct Buffer
{
this(size_t size)
{
On Thursday, 17 December 2020 at 16:11:37 UTC, IGotD- wrote:
It's common using arrays for buffering, that means constantly
adding elements and empty the elements. I have seen that when
the number of elements is zero, the array implementation
deallocates the array which is shown with capacity is
On Thursday, 17 December 2020 at 16:46:47 UTC, Q. Schroll wrote:
On Thursday, 17 December 2020 at 16:11:37 UTC, IGotD- wrote:
It's common using arrays for buffering
Outside of CTFE, use an Appender.¹ Unless you're having a
const/immutable element type, Appender can shrink and reuse
space.² I
On Thursday, 17 December 2020 at 16:11:37 UTC, IGotD- wrote:
It's common using arrays for buffering
Outside of CTFE, use an Appender.¹ Unless you're having a
const/immutable element type, Appender can shrink and reuse
space.² If you have, reallocation is necessary anyway not to
break const/i
On 12/17/20 8:11 AM, IGotD- wrote:
> It's common using arrays for buffering, that means constantly adding
> elements and empty the elements.
I show an example of this at the following point in a DConf presentation:
https://youtu.be/dRORNQIB2wA?t=791
The following code:
int[] outer;
whi
It's common using arrays for buffering, that means constantly
adding elements and empty the elements. I have seen that when the
number of elements is zero, the array implementation deallocates
the array which is shown with capacity is zero. This of course
leads to constant allocation and deallo
On Tuesday, 15 December 2020 at 20:38:04 UTC, Dave P. wrote:
The use case would be to define extension methods on a struct
outside of where the struct is defined. The extension method
mutates the state of the struct, so I want to ensure I am
modifying the original struct and not a copy. If it’s
On Tuesday, 15 December 2020 at 16:25:29 UTC, Trustee wrote:
connect a basic vibe-d app to a graphql backend.
umm, what?
Did you mean write graphql backend using vibe.d?
22 matches
Mail list logo