Hello, I have some doubts about working `formattedRead` with
space chars.
Example:
```d
import std : formattedRead, DateTime, stderr, each;
DateTime parseDT(string str)
{
int d,mo,y, h,m,s;
formattedRead!"%d/%d/%d %d:%d:%d"(str, d,mo,y, h,m,s);
return DateTime(y,mo,d, h,m,s);
}
voi
On Friday, 26 March 2021 at 12:13:29 UTC, kinke wrote:
A class *reference* is always a POD. Only structs can be
non-PODs.
In this case what means "does not have virtual functions, does
not inherit"? Structs doesn't have virtual methods and they can't
inherits.
Hi all!
class Foo
{
private int val;
this(int v) { val = v; }
int vv() { return val*2; }
~this() { }
}
class Bar : Foo
{
this(int v) { super(v); }
override int vv() { return val*3; }
}
pragma(msg, __traits(isPOD, Foo));
pragma(msg, __traits(isPOD, Bar));
prints
true
t
On Friday, 28 August 2020 at 11:50:35 UTC, kinke wrote:
On Friday, 28 August 2020 at 11:46:15 UTC, Oleg B wrote:
How to do this more clearly?
alias Dg = ref int delegate();
Dg foo;
Thanks!
Hello all!
syntax
ref int delegate() foo0;
or
ref(int) delegate() foo1;
or
int delegate() ref foo2;
are not valid.
if I try alias
alias refint = ref int;
refint delegate() foo3;
foo3 have type `int delegate()` (without `ref`)
and it can't store delegate from object me
On Thursday, 30 July 2020 at 14:52:17 UTC, H. S. Teoh wrote:
On Thu, Jul 30, 2020 at 01:41:05PM +, Oleg B via
Digitalmars-d-learn wrote: [...]
Logically we can compare versions, but what must return
`opCmp` if one of versions has 'not comparible' state?
[...]
opCmp is allowed
Hello!
For example we can imagine struct Version.
Version can be old or new and can be 'badly formed' or
'undefined' or other 'not comparible' ('uncompatible') state.
Logically we can compare versions, but what must return `opCmp`
if one of versions has 'not comparible' state?
I think strat
Hello all
I think this code must get compilation error, but it didn't,
furthermore result program get UB.
https://run.dlang.io/is/Qpr278
Is this correct behavior and why?
On Thursday, 25 July 2019 at 12:34:15 UTC, rikki cattermole wrote:
Those restrictions don't stop at runtime.
It's vary sad.
What reason for such restrictions? It's fundamental idea or
temporary implementation?
On Thursday, 25 July 2019 at 12:20:04 UTC, Mike Franklin wrote:
If you read the documentation for betterC
(https://dlang.org/spec/betterc.html#consequences) you'll see
that there are features of the D language which are not
supported. Therefore, libraries that use such features (e.g.
std.for
Hello everyone!
I try build this code with betterC
import core.stdc.stdio;
import std.format : format;
extern(C) int main()
{
mixin(format!`enum str = "%s\0";`("hello"));
fprintf(stderr, "%s\n", str.ptr);
return 0;
}
but compilation fails
/dlang/dmd/linux/bin64/../../src/phobos/st
Hello. I try compile simple example:
import core.stdc.stdio;
import std.algorithm : min;
extern (C) void main()
{
char[256] buf;
buf[] = '\0';
auto str = "hello world";
auto ln = min(buf.length, str.length);
buf[0..ln] = str[0..ln];
printf("%s\n", buf.ptr);
}
rdmd -bett
On Wednesday, 25 October 2017 at 03:36:54 UTC, Adam D. Ruppe
wrote:
I'd suggest just trying it and seeing if the functions return
what you expect.
Unfortunately they returns unexpected codes. Otherwise I wouldn't
post question here. I go here then I have no idea to resolve
problem.
On Wednesday, 25 October 2017 at 04:30:12 UTC, Basile B. wrote:
On Wednesday, 25 October 2017 at 03:12:56 UTC, Oleg B wrote:
2. `array[A..B] of TFoo` is `TFoo[B-A+1]` (static array)
No A-B. In Pascal the upper bound of a range (like here but i'm
not sure this i called like that i
Hello. I have DLL written on Pascal and "headers" for use it
(types and functions signatures definitions). How I can port
"headers" to D?
Calling convention is `stdcall` (`extern (Windows)` for D),
arguments of some functions is structs of structs and etc with
static array fields:
```Pascal
On Tuesday, 3 October 2017 at 12:32:43 UTC, kdevel wrote:
IMHO a program should sleep (consume 0 CPU time and 0 energy)
if there is nothing to process. This is best accomplished by
not polling on a file descriptor in order to check if data has
arrived. If your program must yield() there's proba
On Tuesday, 3 October 2017 at 10:45:21 UTC, kdevel wrote:
On Tuesday, 3 October 2017 at 00:22:28 UTC, Oleg B wrote:
but get error "Resource temporarily unavailable".
You get EAGAIN because there is no data available at the time
of reading.
From the manpage of read:
ERRORS
On Tuesday, 3 October 2017 at 10:45:21 UTC, kdevel wrote:
On Tuesday, 3 October 2017 at 00:22:28 UTC, Oleg B wrote:
but get error "Resource temporarily unavailable".
You get EAGAIN because there is no data available at the time
of reading.
From the manpage of read:
ERRORS
Hello. I run program through std.process.pipeShell and want to
read from it stdout in loop. How do this non-blocking?
I try
int fd = p.stdout.fileno;
int flags = fcntl(fd, F_GETFL, 0);
flags |= O_NONBLOCK;
fcntl(fd, F_SETFL, flags);
but get error "Resource tempo
Hello. I try using destructor in betterC code and it's work if
outer function doesn't return value (void). Code in `scope
(exit)` works as same (if func is void all is ok).
In documentation I found
https://dlang.org/spec/betterc.html#consequences 12 paragraph:
Struct deconstructors.
Why str
On Wednesday, 16 August 2017 at 22:48:59 UTC, Meta wrote:
It's hard to tell offhand but I would recommend that you
extract the inner string into a function that generates that
string, allowing you to print out the finished product before
mixing it in.
It's have a same result...
I want declare only signature of function and build body code by
CTFE.
module mdl;
import std.stdio;
import std.traits;
import std.string;
enum autofnc;
@autofnc
{
int foo(int);
int bar(int);
}
void main()
{
writeln(foo(12));
}
mixin cfuncR;
mixin template cfuncR()
{
On Tuesday, 30 May 2017 at 21:42:03 UTC, Daniel Kozak wrote:
Compiler do many assumptions (it is sometimes useful).
but if compiler find one-to-one correspondence it don't make
assumptions, like here?
import std.stdio;
void f(ushort u)
{
writeln("ushort");
}
void f(ubyte u)
{
writ
and this is unexpected for me too
immutable ushort y = 0;
foo(y); // byte
Hello. I have this code
import std.stdio;
void foo(byte a) { writeln(typeof(a).stringof); }
void foo(short a) { writeln(typeof(a).stringof); }
void foo(int a) { writeln(typeof(a).stringof); }
void main()
{
foo(0); // int, and byte if not define foo(int)
foo(ushort(0)); // byte (unexpect
Hello. I found strange behavior while casting enum array and
immutable array.
import std.stdio;
void main()
{
enum arr = cast(ubyte[])[0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4];
auto arr1 = cast(void[])arr;
immutable arr2 = cast(immutable(void)[])arr;
enum arr3 = cast(void[])arr;
w
Hello. I have this code:
```d
import std.traits;
enum myuda;
class A { @myuda int x; }
class B : A
{
@myuda int some;
void foo() { foreach (s; getSymbolsByUDA!(typeof(this),
myuda)) {} }
}
void main() { (new B).foo(); }
```
And have this error:
```
% rdmd uda_symbols.d
/usr/includ
Hello. Is this behavior normal, or it's a bug? And if it's normal
why it's normal? I want to use function with `package` visibility
in same package where it's defined, but I don't.
```d
module package_visible;
package void foo() { }
void main() { foo(); }
```
```
% rdmd package_visible.d
packa
On Wednesday, 23 November 2016 at 21:04:38 UTC, Christian Köstlin
wrote:
std.concurrency contains the register function to associate a
name with
a Tid. This is stored internally in an associative array
namesByTid.
I see no accessors for this. Is there a way to get to the
associated
names of a
On Wednesday, 8 February 2017 at 16:21:49 UTC, kinke wrote:
On Wednesday, 8 February 2017 at 14:57:41 UTC, Oleg B wrote:
Hello all! I want to build ldc cross compiller. I found this
instruction
https://wiki.dlang.org/LDC_cross-compilation_for_ARM_GNU/Linux, but I have some doubts: will it
Hello all! I want to build ldc cross compiller. I found this
instruction
https://wiki.dlang.org/LDC_cross-compilation_for_ARM_GNU/Linux,
but I have some doubts: will it works with ldc-1.1.0?
Particularly interested in the patch
https://gist.githubusercontent.com/claudemr/3367c13095b15d449b159
Hello.
In std.xml docs I read that is deprecated, and std.net.curl can
be deprecated too (not remember here I read about std.net.curl).
About std.json I read what it's has slow (de)serialization.
What I must use at this time?
vibe.data.json has evolution
https://github.com/s-ludwig/std_data_j
Hello
struct WTable
{
...
private enum opApply_body = q{
if( smt )
{
foreach( f; 0 .. size-1 )
foreach( t; f+1 .. size )
if( auto r = dlg(f,t,data[getIndex(f,t)]) )
return r;
}
else
{
foreach
On Friday, 28 August 2015 at 18:46:23 UTC, Oleg wrote:
I found solution. I call length instead of reserve. It calls
ensureInitialized and everything works fine. By default, Array
won't initialize store.
Oh, reserve calls it too. My mistake.
I found the problem, that's because I
On Friday, 28 August 2015 at 18:40:33 UTC, John Colvin wrote:
On Friday, 28 August 2015 at 18:31:00 UTC, Oleg wrote:
On Friday, 28 August 2015 at 18:21:04 UTC, John Colvin wrote:
On Friday, 28 August 2015 at 17:45:21 UTC, Oleg wrote:
Hello!
Is it possible to get pointer to a data in
On Friday, 28 August 2015 at 18:21:04 UTC, John Colvin wrote:
On Friday, 28 August 2015 at 17:45:21 UTC, Oleg wrote:
Hello!
Is it possible to get pointer to a data in std.container.Array
like .ptr from an array? I need to pass a pointer to some C
function (from DerelictGL3 binding) and avoid
Hello!
Is it possible to get pointer to a data in std.container.Array
like .ptr from an array? I need to pass a pointer to some C
function (from DerelictGL3 binding) and avoid GC allocation.
Thank you!
I found it
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/lifetime.d#L1350
Creates new questions.
Why it's extern(C)?
What must do collectHandler function?
If I understand correctly monitor relates to multithreading
control (Mutex?).
Hello. In object.di rt_finalize calls for class objects in
destroy func.
I not found it in dmd source on github and not found in druntime
sources.
I think rt_finalize must call dtors for object and base classes,
but I think that's not all. Or if it all has it code logic
problems?
void myDestr
On Monday, 8 June 2015 at 13:37:40 UTC, Marc Schütz wrote:
On Monday, 8 June 2015 at 12:24:56 UTC, Oleg B wrote:
I guess you should follow andrei's post about new allocators!
Can you get link to this post?
These are some of his posts:
http://forum.dlang.org/thread/mku0n4$
I guess you should follow andrei's post about new allocators!
Did you mean this article
http://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation
?
I guess you should follow andrei's post about new allocators!
Can you get link to this post?
No just reserve some memory and preallocate the buffer you want
before using it. It'll be a lot faster and cheaper.
I know, it's only for test.
You shouldn't be using delete or new for that matter.
You should be using malloc + free. And emplace.
auto myalloc(T)( size_t count )
{
struct Im
Hello. I want to try use D without GC and I'm not sure what I do
all right.
import core.memory;
version( gcdis ) enum gc_disable = true;
else enum gc_disable = false;
class Foo
{
byte[][] buf;
this()
{
foreach( i; 0 .. 32 )
buf ~= new byte[]( 65536 *
On Monday, 12 January 2015 at 16:44:42 UTC, ketmar via
Digitalmars-d-learn wrote:
nope, it means exactly what is written there. except that
dynamic array
is represented by struct like this:
struct {
void *dataptr;
size_t itemCount;
}
this is what D calls "dynamic array", and this i
On Monday, 12 January 2015 at 15:59:43 UTC, Adam D. Ruppe wrote:
Why are you using ref? Take that off and you can pass any
array, including null, with ease.
Because dynamic arrays are passed by value to functions. Will it
make another copy of array, if I'll pass array by value?
Looks like it
Hello. How can I call a function with null as parameter, which I
don't want to set. For example:
void foo(ref int[] param1) {}
I can't call this function like:
foo(null);
Is it possible to set default value for an array parameter or
pass null/empty array? I can create empty array and pass it, bu
Is this behavior normal or it's bug?
[code]
import std.stdio;
class A
{
float func( float x )
in
{
assert( x > 0 );
stderr.writeln( "A.func in block" );
}
body
{
stderr.writeln( "A.func body block" );
return x / 3;
}
}
class B : A
{
struct FooPasted(Args...){}
class A
{
mixin foo;
void func1() @mark { ... }
void func2( int x, string a ) @mark { ... }
}
must change to:
class A
{
void func1() @mark { ... }
void func2( int x, string a ) @mark { ... }
FooPasted!() func1_mark;
FooPasted!(int,string) func2_mark;
}
I want to write mixin template, what past and/or change some code
in class. Mixin must get all functions with user defined
attribute and past fields for example. It should looks like this
struct FooPasted(Args...){}
class A
{
mixin foo;
void func1() @mark { ... }
void func2( int x, string a )
renaming struct from 'Client' to 'MClient' resolve question
the same result of building release or profile
When I build my program with release flag I get an errors, in
debug build all works
.dub/build/application-profile-linux.posix-x86_64-dmd-AD20DEA65FEE410217932549C1D262EF/ftree.o:
In function
`_D3des4flow5event5Event27__T6__ctorTS6client6ClientZ6__ctorMFNcmKxS6client6ClientZS3des4flow5event5Ev
Hello. I can't find siple way to realization this behavior:
[code]
class A
{
A parent;
void someFunc() const { }
void parentCall() const
{
const(A) cur = this;
while( cur )
{
cur.someFunc();
cur = cur.parent;
}
}
}
[/code]
error: cannot modify const
and when I minimal fix my libs with this issue compiler fails
without any output... =(
% gdb dmd
(gdb) run -unittest matrix.d vector.d
Starting program: /usr/bin/dmd -unittest matrix.d vector.d
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.
On Monday, 25 August 2014 at 11:41:28 UTC, bearophile wrote:
Oleg B:
[code]
void doSome(size_t N, T, string AS)( vec!(N,T,AS) v ) { }
struct vec(size_t N, T, string AS) { T[N] data; }
void main() { doSome( vec!(3,float,"xyz")([1,2,3]) ); }
[/code]
compile with new dmd v2.066.0 and
[code]
void doSome(size_t N, T, string AS)( vec!(N,T,AS) v ) { }
struct vec(size_t N, T, string AS) { T[N] data; }
void main() { doSome( vec!(3,float,"xyz")([1,2,3]) ); }
[/code]
compile with new dmd v2.066.0 and get error:
Error: template opbin.doSome(ulong N, T, string AS)(vec!(N, T,
AS) v) s
On Wednesday, 7 May 2014 at 06:21:10 UTC, Jack wrote:
void* NotUsedAtAll, // Null variable
int argc, // What?
char** results, // Results?
char** columnNames //Column Names?
You can read about this agruments on
http://www.sqlite.org/c3ref/exec.html
Hello.
I'm developing library and want to add an examples to the same
project. If I understand corecly, DUB allows to build a
dependencies from another folder and use them to build a program.
I've tried two ways - subConfigurations and subPackages. For
example, there is subConfigurations confi
why this code get errors?
[code]
/* 1 */struct PData
/* 2 */{
/* 3 */immutable(ubyte)[] data; // ???
/* 4 */pure this(T)( in T val ) { }
/* 5 */}
/* 6 */
/* 7 */unittest
/* 8 */{
/* 9 */immutable(ubyte)[] data_a = [1,2,3];
/* 10 */ubyte[] data_b = [1,2,3];
/* 11 */aut
[code]
import std.stdio;
struct A { int val; }
A a;
class X { const ref A func() { return a; } }
void main()
{
auto x = new X;
x.func().val = 5;
writeln( a );
}
[/code]
in this case 'const' mean 'const method' and variable 'a' changed.
if write
[code]
class X { const(ref A) func(
On Thursday, 14 November 2013 at 21:45:11 UTC, Agustin wrote:
On Thursday, 14 November 2013 at 21:42:38 UTC, Agustin wrote:
On Thursday, 14 November 2013 at 21:20:57 UTC, Oleg B wrote:
[code]
import std.stdio;
interface A { void funcA(); }
class B { final void funcA() { writeln( "B.
[code]
import std.stdio;
interface A { void funcA(); }
class B { final void funcA() { writeln( "B.funcA()" ); } }
class C: B, A { }
void main()
{
auto c = new C;
c.funcA();
}
[code/]
$ dmd -run interface.d
interface.d(6): Error: class interface.C interface function 'void
funcA()' is n
Hello.
I want use one struct in two language.
How to declare the same structure in different languages?
D code: calling C++ function with my struct
extern(C++)
{
struct vec(size_t N, T=float)
{ // << line 6
alias vec!(N,T) thistype;
T[N] data;
auto opBinary(str
by coincidence having same IPs as
> some really banned sites. Availability of those sites is ISP-dependent, as
> different ISPs may implement filtering a bit differently.
>
It is complete OT. In many countries there are some limitations.
BTW, site to which Denis pointed works perfectly for me (Russia, NN,
Beeline).
Oleg.
Hello.
I want use recursion, but in my situation compiler doesn't
correct work.
import std.stdio;
struct MyStruct(uint K)
{
real[K] data;
auto getSmaller()
{
MyStruct!(K-1) ret;
foreach( no, ref d; ret.data )
d = data[no];
return ret;
}
Hello. How to override private methods?
import std.stdio, std.conv;
interface abcInterface
{
private double private_func();
public final double func() { return private_func(); }
}
class abcImpl: abcInterface
{
override private double private_func() { return 3.14; } //#1
}
void main
Problem solved partially.
http://dpaste.dzfl.pl/e7871a01
in structs I use fix length arrays declarations, and alias its to
structs, but not allowed casting to fix length arrays.
I want check array length in compile time
auto opBinary(string op,E)( E[DLen] b ) // fix length array
i
Sorry. My problem more complex and my simplification is not
correct.
I want use mixin for math operations.
mixin template vectOp( string DataName, int DataLen, T, vecType )
{
mixin( "alias " ~ DataName ~ " this;" );
auto opBinary(string op,E)( E[DataLen] b )
auto opBinary(s
Hello. How to cast template struct to itself?
struct vec(string S,T=double)
{
T[S.length] data;
auto opCast(string K,E)()
if( S.length == K.length &&
is( T : E ) )
{
vec!(K,E) ret;
foreach( i, ref m; ret.data )
m = data[i];
retu
solved. its associated with access private for _data field.
if I use alias compiler must replace call "a" (for my type) to
"a._data" if it needs...
bout and references a
> newer one 2830 which looks exactly like the issue.
>
This is fixed issue in D2.061 alpha, but not in D1.
Thanks,
Oleg.
Hello
I have struct in one module (vector.d)
struct vec(string S, T=double)
if( is(T:real) && onlyASCII(S) )
{
private T[S.length] _data;
alias vec!(S,T) ttype;
alias _data this;
mixin _workaround4424;
auto opAssign(E)( E[] b ) if( is( E : T ) )
{
if( b.lengt
s filesystems anyway. Is there any plans to have std.stdio based on
std.stream with UTF16 support for filesystems?
Thaks,
Oleg.
oc.dmp.or (2694428 bytes) in 1.17 s.
"Done"
Much better for C++, but D is not so worse and about 1.1*C++ too.
What we see - different compiler, different story. We should not compare
languages for performance but compilers!
So many differencies in compilers and environment and definetelly C++ is
much more mature for performance now but also D has own benefits (faster
development/debugging and more reliable code).
Thanks,
Oleg.
PS. BTW, this code still can be optimized quite a lot.
75 matches
Mail list logo