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 in the grammar
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
EAGAIN Non
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
EAGAIN Non
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 work
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
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$s35$1...@digitalmar
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 *
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 get error:
[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
43 matches
Mail list logo