On Thursday 20 August 2015 23:11, anonymous wrote:
2) *integer++ doesn't do what you think it does. The increment is done
before the dereference. You could fix this, but:
I got that one wrong. Steven Schveighoffer has it right. The pointer is
incremented after the currently pointed-to value
On Sunday, 16 August 2015 at 23:05:42 UTC, Ali Çehreli wrote:
// Now the type of d is a template parameter
@nogc auto func(Func)(uint[] arr, Func d)
{
return arr.map!(d);
}
Huh. I think func being a template is the key here. When the
original code is put in a template, it works too (with
On Monday, 17 August 2015 at 13:13:48 UTC, anonymous wrote:
and figured out that the linker is invoked (on my machine) with
gcc a.o -o a -m64 -lcurl -L/usr/lib/x86_64-linux-gnu -Xlinker
correct (I named the example programm a.d instead of app.d):
gcc app.o -o app -m64 -lcurl
On Monday, 17 August 2015 at 10:28:33 UTC, thedeemon wrote:
Nope, it works only because r is unreferenced and gets
thrown out. Just try using r.front there, for example, and the
error returns.
You're right, it falls short.
But I think r not being referenced is not exactly it. Using front
in
On Monday, 17 August 2015 at 12:58:54 UTC, Adam D. Ruppe wrote:
On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote:
Hovewer, dmd app.d spits a whole bunch of strange error
messages:
try dmd -lcurl app.d and see if that helps.
DMD does not accept -lcurl. From dmd --help:
On Monday, 17 August 2015 at 16:21:16 UTC, thedeemon wrote:
On Monday, 17 August 2015 at 16:18:50 UTC, thedeemon wrote:
I've just checked with my runtime GC hook. Here the call to
func() allocates 12 bytes via gc_malloc, and it's the same for
a 4-elements array, so it's not for the array
On Sunday, 16 August 2015 at 11:25:48 UTC, Nordlöw wrote:
I tried rebuilding my knowledge graph project at
https://github.com/nordlow/justd/tree/master/knet
with DMD 2.068 and it seems like we have a regression in
std.traits: EnumMembers:
[...]
It builds without errors nor warnings on
On Saturday, 15 August 2015 at 19:50:56 UTC, Temtaime wrote:
There's a problem with « dst[0 .. n] = val; ».
It should be « dst[0 .. n][] = val; »
No, you don't need the `[]`.
On Saturday, 15 August 2015 at 18:04:30 UTC, D_Learner wrote:
memcpy(skip[0], skip[0]+shift, (m-shift)*(int.sizeof));
memset(skip[0]+(m-shift),0, shift*(int.sizeof))
I was thinking conversion would be :-
skip[0 .. size-1] = skip[shift .. size-1 ]; //For the
memcpy();
Those
On Friday, 14 August 2015 at 07:04:53 UTC, BBasile wrote:
It's because of the key type (string is a library type).
This is not true. It's not because of the key type. And string is
not a library type.
On Saturday, 15 August 2015 at 02:21:46 UTC, D_Learner wrote:
Well, the actual error I got is : Error: memset cannot be
interpreted at compile time, because it has no available source
code . I seems to suggest I miss the actual code.
I guess I gave you a wrong impression of how pure relates
On Saturday, 15 August 2015 at 02:21:46 UTC, D_Learner wrote:
On Saturday, 15 August 2015 at 01:13:02 UTC, Adam D. Ruppe
wrote:
On Saturday, 15 August 2015 at 01:09:15 UTC, D_Learner wrote:
When writting a pure fucntion involving C non pure functions
like
memcpy() and memset()
Those
https://issues.dlang.org/show_bug.cgi?id=14920
On Thursday, 13 August 2015 at 16:28:15 UTC, learn wrote:
unfortunately i can't find a complete set of windows header
files.
maybe one should add a link for those headers if they exist -
life is not linux or osx only.
https://github.com/etcimon/windows-headers
On Thursday, 13 August 2015 at 19:13:55 UTC, D_Learner wrote:
I was wondering how I could change the code below such the
`bmBc` is computed at compile time . The one below works for
runtime but it is not ideal since I need to know the `bmBc`
table at compile-time . I could appreciate advice
The following alias declaration is totally legal but actually
it's not usable
---
class Foo
{
void something(size_t param){}
}
class Bar
{
private Foo foo;
this(){foo = new Foo;}
alias somethingelse = foo.something;
}
void main(string[] args)
{
auto bar = new Bar;
On Tuesday, 11 August 2015 at 19:56:02 UTC, Suliman wrote:
Date startDate = Date.fromISOExtString(2014-08-01);
[...]
Date nextday;
while (nextday currentDate)
{
nextday = startDate + 1.days;
writeln(nextday);
}
startDate
On Sunday, 9 August 2015 at 20:23:00 UTC, Reflexive wrote:
I see that remove() removes the value of the element but keeps
the same size of the array, and replace the value by a new one
at the end. The method :
class sabot{
card[] sabotarray ;
(...)
card getCard(){
On Sunday, 9 August 2015 at 20:13:38 UTC, ixid wrote:
This seems like a reasonable use but errors, obviously I can do
it in many other ways:
ulong[] result = iota(1UL, 10UL).array;
Error: static assert Argument types in (ulong) are not all
convertible to size_t:
(ulong)
On Sunday, 9 August 2015 at 17:43:59 UTC, 岩倉 澪 wrote:
Afaict it is the best way to do what I'm trying to do, and
since the data is mutable and cast to immutable with
assumeUnique, casting it back to mutable shouldn't be a
problem. Technically casting away immutable might be undefined
On Thursday, 6 August 2015 at 17:01:32 UTC, chris wrote:
since memorystream is deprecated how do i do something like
this with Input and Output ranges? How can i fill up an array
with ranges like you can do with streams?
Thanks.
The InputRange primitives already exist for arrays, they are
On Thursday, 6 August 2015 at 20:21:38 UTC, Carl Sturtivant wrote:
I took the example code from here,
http://dlang.org/phobos/core_thread.html#.Fiber
and wrapped the statements at the bottom inside main() and put
import core.thread and std.stdio at the top, and the compiler
gave me the
On Wednesday, 5 August 2015 at 12:32:48 UTC, cym13 wrote:
For reference, as the diagram was unreadable, I'll describe it
here:
class Adam ;
class Eve ;
class Abel:Adam,Eve ;
class Cain:Adam,Eve ;
class David:Abel,Cain ;
This is illegal D. You must use interfaces to simulate multiple
On Wednesday, 5 August 2015 at 21:02:49 UTC, Andre Polykanine
wrote:
Hi everyone,
I'm fairly new to D and am really excited about it.
I would like to see more examples of Windows programming in D,
but the
repository indicated on the D wiki seems to be moved or deleted.
More info is here:
On Sunday, 2 August 2015 at 08:08:05 UTC, tcak wrote:
[code]
void func1(N)( const N name )
if( is(N: string) || is(N: char[]) )
{
func2( name );
}
void func2(N)( const N name )
if( is(N: string) || is(N: char[]) )
{}
void main(){
char[] blah = ['b', 'l', 'a',
On Friday, 31 July 2015 at 11:09:39 UTC, anonymous wrote:
Definitely a bug. Please file an issue at
https://issues.dlang.org/.
https://issues.dlang.org/show_bug.cgi?id=14858
On Friday, 31 July 2015 at 10:56:33 UTC, vitus wrote:
//Why expression 'foobar(1);' doesn't work?
void foo()(){}
void bar(int){}
alias foobar = foo;
alias foobar = bar;
void main(){
.foobar(1); //OK
foobar(1); //Error: overload alias 'foo' is not a
On Wednesday, 29 July 2015 at 20:20:47 UTC, Adel Mamin wrote:
void my_func(auto arr)
{
writeln(arr);
}
There are no `auto` parameters in D. You have to make it a
template explicitly:
void my_func(A)(A arr)
{
writeln(arr);
}
On Wednesday, 29 July 2015 at 21:33:16 UTC, remi thebault wrote:
Hello
I have this weird error trying to achieve something simple:
That's far from simple.
Here's a reduction:
template wl_container_of(alias member)
{
size_t get() {return member.offsetof;}
}
struct item { int link;
On Wednesday, 29 July 2015 at 17:59:26 UTC, Kyoji Klyden wrote:
How would I use a C function that's returning a struct? auto
doesn't work here, and from what I can tell D can't import C
headers. (If it really can't then, that would be a very welcome
feature)
I do have the required libs but I
On Tuesday, 28 July 2015 at 22:52:31 UTC, Binarydepth wrote:
I'm reading the reference : http://dlang.org/arrays.html
And I'm declaring two dynamic arrays as I understand. What I
had in mind was declaring a dynamic array of two elements each.
int[2][] is exactly an dynamic array of (arrays
On Tuesday, 28 July 2015 at 16:41:40 UTC, Binarydepth wrote:
It works with 2 as input but shows error when number is 3 :(
I can't reproduce that or I misunderstood something:
$ cat a.d
import std.stdio : readf, writef;
void main(){
int[2][] nam;
int num;
readf(
On Tuesday, 28 July 2015 at 16:09:46 UTC, Binarydepth wrote:
Here is what I'm trying to do :
import std.stdio : readf, writef;
void main() {
int[2][] nam;
int num;
readf( %d, num);
nam.length = num;
foreach(nim; 0..num){
readf( %d
On Tuesday, 28 July 2015 at 21:12:13 UTC, Johan Engelen wrote:
Hi all,
I am wondering if there is any Phobos functionality for
indexing into a list using a type. What I mean is something
like:
assert( somethingie!(float, float, double, real)(1, 22, 333)
== 1 );
assert(
On Monday, 27 July 2015 at 12:03:06 UTC, Vlad Leberstein wrote:
Hi! My use case requires interaction with C API which in turn
implies storing object instance reference as void *. I'm using
gdc 4.9.2 and everything worked fine with object - void * -
object conversion, but object - void * -
On Monday, 27 July 2015 at 13:11:33 UTC, anonymous wrote:
In the first example, you pass a pointer to a class instance.
You cannot get the vtbl entry for the interface like this.
Instead try to do this in 2 steps:
actually i meant you pass an untyped pointer, so when you cast as
interface
On Monday, 27 July 2015 at 16:48:00 UTC, Alex wrote:
Okay. By pure trying I found out what I did wrong:
Apparently by typing Y I entered the shift key. Could that have
been the problem?
I changed it to a small y and it at least jumped back to the
commandline instead of just being stuck.
And
On Sunday, 26 July 2015 at 11:38:31 UTC, simendsjo wrote:
Is there a reason why you would hide the fact that a function
is trusted rather than safe? Technically it doesn't matter,
right? To me, it seems like this would give wrong assumptions
to the caller.
The reason I ask is because I found
On Friday, 24 July 2015 at 18:55:26 UTC, Frank Pagliughi wrote:
So then, of course, I hope/wonder/assume that the pointer to
the heap is sufficient to keep the heap memory alive, and that
this would be OK from the GC perspective to do something like
this:
B* make_b_thing(int i) { cast(B*)
On Friday, 24 July 2015 at 21:51:44 UTC, Frank Pagliughi wrote:
So then: is there a pointer notation to which you can cast the
B reference, which thus points to the heap, but retains type
identity of the heap object?
There's no straight forward way to do that. D has no types for
the actual
On Monday, 20 July 2015 at 08:53:52 UTC, Clayton wrote:
What could be the best-tool for monitoring the evaluation time
of a variable . What I usually do is run the command :-
- dmd -J. program.d
Then I inspect the program.o file using vi for presence of
compile-time constants and enums. I am
On Saturday, 18 July 2015 at 16:18:30 UTC, Clayton wrote:
Thanks , you were right . It seems there are some key words
though which one has to use so that the code gets executed on
compile-time .For example I had to change the second forloop to
a foreach loop,
`for` loops work just fine in
On Friday, 17 July 2015 at 07:42:09 UTC, Roland Hadinger wrote:
Here's how I would implement the basic behaviour (could be
extended to also forward bidirectional and random access
functions):
---
auto cushion(R)(R r)
if (isInputRange!R)
{
static if (isInfinite!R) {
On Friday, 17 July 2015 at 07:54:43 UTC, FreeSlave wrote:
On Friday, 17 July 2015 at 07:33:43 UTC, Anonymous wrote:
On Friday, 17 July 2015 at 07:14:24 UTC, FreeSlave wrote:
On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote:
I have the following code, working under Win and Linux:
On Friday, 17 July 2015 at 07:14:24 UTC, FreeSlave wrote:
On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote:
I have the following code, working under Win and Linux:
---
import std.process: environment;
immutable string p;
static this() {
version(Win32) p =
On Friday, 17 July 2015 at 12:18:56 UTC, TC wrote:
Hello,
I came around a strange behavior and I'm not sure if it is a
bug or feature.
import std.typecons : Nullable;
struct Foo
{
string bar;
Nullable!int baz;
}
auto a = Foo(bb);
auto b = Foo(bb);
assert(a == b);
This ends
I have the following code, working under Win and Linux:
---
import std.process: environment;
immutable string p;
static this() {
version(Win32) p = environment.get(APPDATA);
version(linux) p = /home/ ~ environment.get(USER);
version(OSX) p = ?;
}
---
what would be the OSX
On Tuesday, 14 July 2015 at 01:05:21 UTC, jmh530 wrote:
Note: some of the above seemed to only work when I kept the
std.math.cos, std.math.sin text in there. When I take it out, I
get warnings about recursive aliases.
Yeah, you can't do `alias cos = givemeabettername!cos;`. That
would define
On Tuesday, 14 July 2015 at 14:02:46 UTC, jmh530 wrote:
Thanks for posting that. I figured out the issue. Before you
had recommended that I use
alias cos = std.math.cos;
I had kept that text in. When I removed it, everything worked
just fine. I'm still not sure I grasp the subtleties of alias
On Sunday, 12 July 2015 at 21:07:34 UTC, jmh530 wrote:
private template givemeabettername(alias fun)
{
T givemeabettername(T : U[], U)(T x)
if (isArray!(T))
{
return x.map!(a = fun(a)).array;
You don't need the lambda, do you? - return x.map!fun.array;
}
}
Very
On Sunday, 12 July 2015 at 16:34:17 UTC, jmh530 wrote:
I've been playing around with this a little more. I wrote this
function to encapsulate a simple operation on arrays.
U array_fun(T, U)(T fp, U x)
if (isFunctionPointer!(T) isArray!(U))
{
return x.map!(a = fp(a)).array;
}
On Sunday, 12 July 2015 at 17:25:17 UTC, Gary Willoughby wrote:
Why does the following code fail to compile if the
`writeln(value);` line is present?
The error message (formatted to be a little more readable):
Error: function test2.__unittestL6_1.Foo.opApply
(int delegate(ref string)
On Saturday, 11 July 2015 at 13:31:12 UTC, Peter wrote:
The postblit can only not take @nogc due to the array
duplication which is understandable.
I think the postblit might be redundant anyway since the struct
is built on a static array so there is no possibility of two
different Vect3s
On Friday, 10 July 2015 at 03:11:25 UTC, Mike Parker wrote:
On Friday, 10 July 2015 at 00:53:38 UTC, codenstuff wrote:
The path is ${HOME}/d_apps/steering/steering/game_object.d
[...]
First, because you are importing sterring.game_object, then you
can't pass -I/home/real/d_apps/steering to
On Friday, 10 July 2015 at 00:53:38 UTC, codenstuff wrote:
On Friday, 10 July 2015 at 00:24:44 UTC, anonymous wrote:
On Thursday, 9 July 2015 at 22:05:23 UTC, codenstuff wrote:
I am trying to import module and compile.
The compiler produces message
map/map.d(9): Error: module game_object is
On Thursday, 9 July 2015 at 22:05:23 UTC, codenstuff wrote:
I am trying to import module and compile.
The compiler produces message
map/map.d(9): Error: module game_object is in file
'steering/game_object.d' which cannot be read
import path[0] = /usr/include/dmd/phobos
import path[1] =
On Tuesday, 7 July 2015 at 19:54:19 UTC, jmh530 wrote:
I'm not sure I understand the safety of function pointers vs.
the addresses of functions. The code below illustrates the
issue.
I was under the impression that pointers are not allowed in
safe code.
No, pointers are fine. It's pointer
On Tuesday, 7 July 2015 at 20:32:49 UTC, jmh530 wrote:
Thanks for the detailed answer. All I meant here is that if I
have some
T foo(T)(T x), then to take the address, sometimes I've needed
to foo!int or foo!real, etc.
Ah, sure. Templates don't have addresses. Function templates are
not
On Monday, 6 July 2015 at 07:48:17 UTC, sigod wrote:
Aren't compiler smart enough to prevent it?
```
ubyte[] test1()
{
auto b = sha1Of();
return b; // Error: escaping reference to local b
}
ubyte[] test2()
{
return sha1Of(); // works, but returns incorrect data
}
```
On Monday, 6 July 2015 at 01:16:54 UTC, Peter wrote:
Hi,
I have a struct with arithmetic operations defined using
opBinary but array operations with arrays of it don't work.
struct Vector3 {
public double[3] _p;
...
Vector3 opBinary(string op)(in Vector3 rhs) const
if (op ==
On Monday, 6 July 2015 at 03:02:59 UTC, Nicholas Wilson wrote:
On Monday, 6 July 2015 at 01:16:54 UTC, Peter wrote:
[...]
unittest{
auto a = Vector3([2.0, 2.0, 0.0]);
auto b = Vector3([1.0, 2.0, 1.0]);
Vector3[] c = [a];
Vector3[] d = [b];
Vector3 e = a + b; // works
On Monday, 6 July 2015 at 12:15:22 UTC, Peter wrote:
dmd 2.066.1, windows 7 64bit
Tested it on Windows 7, using dmd 2.066.1: works for me.
The exact code I tested (just commented those ... out):
struct Vector3 {
public double[3] _p;
//...
Vector3 opBinary(string op)(in
On Monday, 6 July 2015 at 20:50:19 UTC, Gary Willoughby wrote:
How do you correctly implement a bidirectional range on a
linked list?
I have a linked list implementation and I've added a range
interface to it but after a while I've realized it not quite
right. The problem is when I call the
On Monday, 6 July 2015 at 21:58:31 UTC, anonymous wrote:
To make your removal methods stable, it may be enough to not
free the removed node. That is, don't do this:
https://github.com/nomad-software/etcetera/blob/master/source/etcetera/collection
Looks like I messed up the URL. Here's the
On Thursday, 2 July 2015 at 17:33:29 UTC, Laeeth Isharc wrote:
Any thoughts on what could be leading to the following:
./../../marketdata/source/pricebar.d(397): Error: incompatible
types for ((bar.high) + (bar.low)): 'FixedDecimal!(int, 8)' and
'FixedDecimal!(int, 8)'
On Thursday, 2 July 2015 at 19:03:49 UTC, dd0s wrote:
i got a date t described in seconds from 1.1.1970,
I.e., you have a unix timestamp.
and i want to check if the current time is further than 12
hours from the given time t. the following code works but it's
super ugly =S
please give me
On Wednesday, 1 July 2015 at 20:01:08 UTC, dd0s wrote:
i have the following struct, and i expect it to have 30 bytes
but sizeof tells me it has 32 bytes. dmd seems to still use
4byte alignment altough i specified to align 2bytes.
struct netadr_t {
align(2):
inttype; // 0
On Wednesday, 1 July 2015 at 17:13:03 UTC, Taylor Hillegeist
wrote:
string q = cast(string)
(A.cycle.take(seg1len).array
~B.cycle.take(seg2len).array
~C.cycle.take(seg3len).array);
q.writeln;
I was wondering if it might be the cast?
Yes, the cast is wrong. You're reinterpreting (not
On Sunday, 28 June 2015 at 16:28:20 UTC, jmh530 wrote:
Thanks for the reply. Two follow ups: 1) Does labeling a
template as pure matter if the compiler infers it anyway? 2)
Does the compiler also infer anything for @safe/nothrow in
templates?
1) It means you can't instantiate the template
On Tuesday, 30 June 2015 at 15:18:36 UTC, Jack Applegame wrote:
Just creating a bunch (10k) of sleeping (for 100 msecs)
goroutines/tasks.
Compilers
go: go version go1.4.2 linux/amd64
vibe.d: DMD64 D Compiler v2.067.1 linux/amd64, vibe.d 0.7.23
Code
go: http://pastebin.com/2zBnGBpt
On Monday, 29 June 2015 at 12:04:46 UTC, Jonathan M Davis wrote:
You haven't declared an immutable constructor, so you can't
construct an immutable Foo.
That's not what's happening. Constructing an immutable Foo works
just fine.
On Monday, 29 June 2015 at 22:11:16 UTC, sigod wrote:
`new immutable(MyClass)()` is invalid code.
It's perfectly fine, actually.
On Sunday, 28 June 2015 at 09:19:16 UTC, Tofu Ninja wrote:
module main;
import std.stdio;
void main(string[] args)
{
auto d = foo();
writeln(d()); // prints 25
}
auto foo()
{
int x = 4;
pure int delegate() d = delegate()
{
return x*x;
On Sunday, 28 June 2015 at 01:57:46 UTC, xky wrote:
hello. :-)
when i was using DerelictSFML2(
http://code.dlang.org/packages/derelict-sfml2 ), i got this
problem.
CSFML doc had 'setUnicodeString':
On Tuesday, 23 June 2015 at 07:57:26 UTC, Charles Hawkins wrote:
Sigh. I'm probably doing something stupid. I tried full paths:
dmd -I+/home/charles/projects/d/mylib/source/mylib/ myprog.d
What's that plus sign doing there? Looks wrong.
/home/charles/projects/d/mylib/build/libmylib.a
Same
On Monday, 22 June 2015 at 20:30:40 UTC, David DeWitt wrote:
I am getting an core.exception.InvalidMemoryOperationError@(0)
auto recs = f // Open for reading
.byLineCopy();
.array; //Here is where is appears
to be happening.
I have
On Monday, 22 June 2015 at 18:44:22 UTC, Assembly wrote:
I'm using this, thanks for all. Can someone clarify how does
opApply() works? I assume it's called every iteration and as
opApply() has a loop does it means the number of iteration ran
actually is the ones from foreach() is 2*n where n
On Tuesday, 16 June 2015 at 21:17:37 UTC, tcak wrote:
As far as I known, when I define a string with enum and it is
used at different parts of code, that string is repeated again
and again in executable file instead of passing a pointer to
string. So, using enum with string doesn't seem like a
On Monday, 15 June 2015 at 15:10:24 UTC, jmh530 wrote:
float[] exp(float[] x) {
auto y = x.map!(a = exp(a));
cast(float[]) y;
return y;
}
But I get an error that I can't convert MapResult!(__lambda2,
float[]) to float[].
So I suppose I have two questions: 1) am I
On Sunday, 14 June 2015 at 10:10:51 UTC, ketmar wrote:
i.e. when it need a value in compile time. the interpreter is
invoked, it evaluates (interprets) the given code (function or
template instantiation), and then it returns result (or raises
an error).
One important thing I didn't see
On Sunday, 14 June 2015 at 10:41:24 UTC, JDemler wrote:
So if i want to use parameters in a static context at compile
time i have to pass them as template parameters?
Yes, template parameters are fine.
To come back to destructors and immutable objects:
Even without the default initialized variables issue it is
possible to modify immutable data:
struct S {
int[] bar;
~this() {
bar[0] = 123;
}
}
void foo(immutable(int[]) i) {
immutable(S) s = immutable S(i);
}
void main() {
On Saturday, 13 June 2015 at 00:47:37 UTC, Mike Parker wrote:
// config.d
version(One) enum One = true;
else enum One = false;
version(Two) enum Two = true;
else enum Two = false;
// other.d
import config;
static if(One || Two) {
...
}
Taking it one step further:
template Version(string
On Saturday, 13 June 2015 at 15:21:19 UTC, Dennis Ritchie wrote:
Hello, everyone!
I like to work with arrays of strings like `string[] strArray`,
but unfortunately, they are immutable.
I do not like to work with arrays of strings such as `char[][]
strArray`, because it is necessary to apply
On Saturday, 13 June 2015 at 17:02:06 UTC, Dennis Ritchie wrote:
On Saturday, 13 June 2015 at 16:20:46 UTC, anonymous wrote:
[...]
Yeah, that would be neat. But typing out .dup isn't that
bad, and converting a `string[]` to a `char[][]` is simple:
import std.conv: to;
auto a =
On Saturday, 13 June 2015 at 15:58:44 UTC, Dennis Ritchie wrote:
On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote:
Before jumping to a solution, please elaborate on the
perceived problem. I have a feeling that there is none.
Do you like to write?
char[][] strArray = [foo.dup,
On Saturday, 13 June 2015 at 16:09:58 UTC, Dennis Ritchie wrote:
On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote:
[...]
Are you saying that `string[]` is simpler than `char[][]`?
That's not true: `string` is an alias for `immutable(char)[]`,
so `string[]` is the same as
Is there an existing issue on issue.dlang.org? If not can you
report it
https://issues.dlang.org/show_bug.cgi?id=10376
no need for ~this() to modify immutable data:
class C {
int a;
this(int a) {
this.a = a;
}
}
struct S {
C elem = new C(42);
}
void main() {
import std.stdio;
immutable(S) s1;
// Error: cannot modify immutable expression
I cannot find a way to actually modify immutable memory with
it...
a.d:
class C {
int a;
this(int a) {
this.a = a;
}
}
struct S {
int x;
C elem = new C(42);
~this() {
import std.stdio;
writeln(mutable ~this());
x = 1;
elem.a = 123;
On Thursday, 11 June 2015 at 19:56:00 UTC, kerdemdemir wrote:
Can I achieve something faster than code below?
auto peopleMoney = stdin.readln().split().map!(a =
to!int(a)).array();
if (peopleMoney.length == 20)
writeln(:();
`std.array.split` is eager. It may be faster if you
On Wednesday, 10 June 2015 at 17:00:34 UTC, Dennis Ritchie wrote:
Isnt it possible to come up with the interpreter compile-time,
which will determine the operating time of the program at
runtime at compile time.
Sounds like the halting problem. So, no, generally this is not
possible.
On Monday, 25 May 2015 at 17:52:09 UTC, Dennis Ritchie wrote:
But why is the solution breaks down when `s = 1` ? :)
import std.stdio, std.algorithm, std.range;
int c;
const x = 12, y = 65, z = 50, s = 10;
Which is it, now? 4 or 5 zeros?
void solve(Range)(Range r) {
On Sunday, 24 May 2015 at 17:35:39 UTC, Jay Norwood wrote:
I'm a bit confused by the documentation of the ctfe limitations
wrt static arrays due to these seemingly conflicting
statements, and the examples didn't seem to clear anything up.
I was wondering if anyone has examples of clever
On Sunday, 24 May 2015 at 18:14:19 UTC, anonymous wrote:
Static array has a special meaning. It does not mean static
variable with an array type. Static arrays are those of the
form Type[size]. That is, the size is known statically.
PS: You may also see the term fixed-size array which means
On Sunday, 24 May 2015 at 20:53:03 UTC, Jay Norwood wrote:
On Sunday, 24 May 2015 at 18:14:19 UTC, anonymous wrote:
[...]
1) static int[5] x; -- x is a static variable with a static
array type
2) static int[] x; -- static variable, dynamic array
3) int[5] x; -- non-static variable, static
On Saturday, 23 May 2015 at 20:25:18 UTC, Dennis Ritchie wrote:
This does not work!
enum n1 = 5;
writeln(stdin.byLine
.map!(line = line.split( ).map!(x = to!int(x)))
);
-
http://rextester.com/VGHZF81178
The code itself is ok.
That site has broken newlines. You can see here that
On Saturday, 23 May 2015 at 21:08:19 UTC, Dennis Ritchie wrote:
Perhaps that's not the site, and in Windows. That's what gives
me in CMD:
456 4 4 8 99 456
[[456, 4, 4, 8, 99, 456]13 546
std.conv.ConvException@C:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(2013):
Unexpected end of input
On Monday, 18 May 2015 at 14:34:38 UTC, ketmar wrote:
it can throw out of range error, which is `new`ed.
Array access can also throw RangeError, but -vgc and @nogc don't
mind that:
void main() @nogc
{
int[] a;
auto b = a[0];
}
On Sunday, 17 May 2015 at 21:34:21 UTC, tcak wrote:
[code]
void test(D)( const D data ) if( is(D: shared(char[]) ) ) { }
void main() {
char[] text = new char[4];
text[0] = 'a'; text[1] = 'b'; text[2] = 'c'; text[3] = 'd';
auto t = cast( shared(const(char[]))
201 - 300 of 560 matches
Mail list logo