Compiler dmd_2.068.0-0_amd64.deb on Ubuntu 12.04 Linux:
auto lookup = [ "one":1, "two":2 ];
The dmd error:
Error: non-constant expression ["one":1, "two":2]
Why doesn't it compile?
As a workaround I could do the assignment one element at a time
in a loop. It would be uglier though.
thanks for the reply...
the method you described is suitable for appending to an array, but I'm
using the singly-linked-list container.
I've extended the test, and I'm pretty sure it's a bug...
--ted
Nicholas Wilson wrote:
> On Thursday, 13 August 2015 at 08:40:13 UTC, ted wrote:
>>
>> have
On Fri, Aug 14, 2015 at 02:42:26AM +, Laeeth Isharc via Digitalmars-d-learn
wrote:
> I have a range that is an array of structs. I would like to iterate
> through the range, calling a function with the prior k items in the
> range up to that point and storing the result of the function in a n
I have a range that is an array of structs. I would like to
iterate through the range, calling a function with the prior k
items in the range up to that point and storing the result of the
function in a new range/array.
what's the best way to do this? for low fixed k I could use zip
with st
On Friday, 14 August 2015 at 00:06:33 UTC, Adam D. Ruppe wrote:
On Thursday, 13 August 2015 at 23:48:08 UTC, Jack Stouffer
wrote:
In my code, the list can have 20-30 different types of classes
in it all inheriting from the same interface, and it doesn't
make sense for all of those classes to im
On Thursday, 13 August 2015 at 23:48:08 UTC, Jack Stouffer wrote:
In my code, the list can have 20-30 different types of classes
in it all inheriting from the same interface, and it doesn't
make sense for all of those classes to implement a method that
is very specific to one of the classes.
On 08/13/2015 04:48 PM, Jack Stouffer wrote:
On Thursday, 13 August 2015 at 22:49:15 UTC, Adam D. Ruppe wrote:
On Thursday, 13 August 2015 at 21:42:54 UTC, Jack Stouffer wrote:
dynamically calling different methods on each object in the list
based on its type.
The cleanest OO way of doing tha
On Thursday, 13 August 2015 at 22:49:15 UTC, Adam D. Ruppe wrote:
On Thursday, 13 August 2015 at 21:42:54 UTC, Jack Stouffer
wrote:
dynamically calling different methods on each object in the
list based on its type.
The cleanest OO way of doing that is to put the methods you
need in the inter
On 08/13/2015 03:36 PM, Tofu Ninja wrote:
On Thursday, 13 August 2015 at 22:29:17 UTC, MrSmith wrote:
http://dlang.org/phobos/core_thread.html#.Fiber
Man I feel like I saw that before but when I went looking for it I
couldn't find it. Didn't think to check in core. :/
Welp that solves my ques
On Thursday, 13 August 2015 at 22:27:31 UTC, Tofu Ninja wrote:
Also how portable is the built in asm support
it varies a bit across compilers (gdc does it differently), and
obviously across processors.
Also is there a way to define naked functions in D?
Put the `naked;` pseudo-instruction
On Thursday, 13 August 2015 at 21:42:54 UTC, Jack Stouffer wrote:
dynamically calling different methods on each object in the
list based on its type.
The cleanest OO way of doing that is to put the methods you need
in the interface and always call it through that. Then there's no
need to cast
On Thursday, 13 August 2015 at 22:20:35 UTC, Justin Whear wrote:
foreach (item; parent_list) {
if (auto asA = cast(A)item) {
asA.method();
} else if (auto asB = cast(B)item) {
asB.method2();
}
}
On Thursday, 13 August 2015 at 22:20:35 UTC, Justin Whear wrote:
Thanks Justin and ru
On Thursday, 13 August 2015 at 22:29:17 UTC, MrSmith wrote:
http://dlang.org/phobos/core_thread.html#.Fiber
Man I feel like I saw that before but when I went looking for it
I couldn't find it. Didn't think to check in core. :/
Welp that solves my question, thanks :D
On Thursday, 13 August 2015 at 21:42:54 UTC, Jack Stouffer wrote:
Thanks, that worked, and based on your answer, I was able to
fix my real problem: dynamically calling different methods on
each object in the list based on its type. So, using the above
code as an example, I am able to call meth
Is there any way to have a yieldable function that can be resumed
at a later time in D?
Some thing like:
void test()
{
writeln("A");
yeild();
writeln("B");
}
...
auto x = yieldable!test();
x.resume(); // prints "A"
x.resume(); // prints "B"
x.resume(); // throws an error or som
http://dlang.org/phobos/core_thread.html#.Fiber
On Thu, 13 Aug 2015 21:42:52 +, Jack Stouffer wrote:
> foreach (item; parent_list) {
> string class_name = (cast(Object)
> item).classinfo.name;
> if (class_name == "test.A") {
> (cast(A) item).method();
> } e
On Thursday, 13 August 2015 at 20:28:33 UTC, Adam D. Ruppe wrote:
On Thursday, 13 August 2015 at 20:23:56 UTC, Jack Stouffer
wrote:
As far as I can tell, there is no way to know the actual type
of each of the objects in the list to be able to print:
Cast it to Object first, then do the typeid
On Thursday, 13 August 2015 at 20:23:56 UTC, Jack Stouffer wrote:
As far as I can tell, there is no way to know the actual type
of each of the objects in the list to be able to print:
Cast it to Object first, then do the typeid and it will get the
dynamic class type. Since Parent is an interfa
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
Given:
interface Parent {
void method();
}
class A : Parent {
void method() {}
this() {}
}
class B : Parent {
void method() {}
void method2() {}
this() {}
}
void main() {
import std.stdio;
Parent[] parent_l
On Thursday, 13 August 2015 at 19:26:12 UTC, Adam D. Ruppe wrote:
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 .
It is currently not possible to build an associative array at
compile
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 on
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 .
It is currently not possible to build an associative array at
compile time and keep it as a runtime table due to the
implementation.
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 on how I could improve
on this.
import std.conv:to;
On Thursday, 13 August 2015 at 17:04:54 UTC, Adam D. Ruppe wrote:
On Thursday, 13 August 2015 at 16:28:15 UTC, learn wrote:
I'm slowly working on getting them into the standard library.
I'm probably one or two more weekends away from getting it to
work (it is harder than I thought because the
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.
I'm slowly working on getting them into the standard library. I'm
probably
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.
On 8/13/15 11:59 AM, Steven Schveighoffer wrote:
That is definitely a bug. It's because typeid is looking up the derived
type via the vtable, but the compiler should rewrap it with 'shared'
afterwards.
Actually, now that I think about it, I'm not sure how the compiler can
figure this out.
T
On 8/12/15 11:46 PM, rsw0x wrote:
Sample code:
class C{}
struct S{}
void main(){
import std.stdio;
auto c = new shared C();
auto s = new shared S();
writeln(typeid(c)); //modulename.C
writeln(typeid(s)); //shared(modulename.S)*
writeln(typeid(c).next); //null
On Thursday, 13 August 2015 at 03:46:19 UTC, rsw0x wrote:
Sample code:
class C{}
struct S{}
void main(){
import std.stdio;
auto c = new shared C();
auto s = new shared S();
writeln(typeid(c)); //modulename.C
writeln(typeid(s)); //shared(modulename.S)*
writeln(typeid(c).n
On 14/08/2015 12:48 a.m., D_Learner wrote:
On Thursday, 13 August 2015 at 12:21:44 UTC, Rikki Cattermole wrote:
On Thursday, 13 August 2015 at 12:07:48 UTC, D_Learner wrote:
I am having this struct :-
struct COMPILETIME_BM_PRE
{
void initialisebmBc(S,C,I,int k)( const S patter
On Thursday, 13 August 2015 at 12:21:44 UTC, Rikki Cattermole
wrote:
On Thursday, 13 August 2015 at 12:07:48 UTC, D_Learner wrote:
I am having this struct :-
struct COMPILETIME_BM_PRE
{
void initialisebmBc(S,C,I,int k)( const S pattern ,ref
I[C] bmBc){
static
On Thursday, 13 August 2015 at 12:07:48 UTC, D_Learner wrote:
I am having this struct :-
struct COMPILETIME_BM_PRE
{
void initialisebmBc(S,C,I,int k)( const S pattern ,ref
I[C] bmBc){
static if ( k< ASIZE ){
bmBc[ALPHABET[k]] = size;
I am having this struct :-
struct COMPILETIME_BM_PRE
{
void initialisebmBc(S,C,I,int k)( const S pattern ,ref I[C]
bmBc){
static if ( k< ASIZE ){
bmBc[ALPHABET[k]] = size;
initialisebmBc!(S,C,I,k+1)( pattern ,bm
On 12/08/2015 10:50 a.m., Clayton wrote:
Hello everyone,
Am looking for someone who could help review my code . As an entry
exercise to D am converting 3 C implementations of popular pattern
matching algorithms. The idea is to have 6 final implementations ( 3
compile-time and 3 runtime) . I thi
On Wednesday, 12 August 2015 at 13:14:04 UTC, sigod wrote:
On Tuesday, 11 August 2015 at 22:50:52 UTC, Clayton wrote:
Hello everyone,
Am looking for someone who could help review my code . As an
entry exercise to D am converting 3 C implementations of
popular pattern matching algorithms. Th
On Wednesday, 12 August 2015 at 12:14:20 UTC, Rikki Cattermole
wrote:
On 13/08/2015 12:09 a.m., Clayton wrote:
On Wednesday, 12 August 2015 at 02:49:59 UTC, Rikki Cattermole
wrote:
On 12/08/2015 10:50 a.m., Clayton wrote:
[...]
Upload to e.g. Github/gist/pastebin.
Hi Rikki, can I have your
trying to comile the minimal console application generated by
visuald:
Building Debug\ConsoleApp1.exe...
LINK : fatal error LNK1104: cannot open file 'libucrtd.lib'
Building Debug\ConsoleApp1.exe failed!
On Thursday, 13 August 2015 at 08:40:13 UTC, ted wrote:
have upgraded from 2.066.1 to 2.068.0, and have a change in
behaviour:
import std.container: SList;
void main()
{
SList!int tmp;
tmp.insertAfter( tmp[], 3 );
}
used to work happily with dmd2.066.1, causes assert
(core.excepti
have upgraded from 2.066.1 to 2.068.0, and have a change in behaviour:
import std.container: SList;
void main()
{
SList!int tmp;
tmp.insertAfter( tmp[], 3 );
}
used to work happily with dmd2.066.1, causes assert
(core.exception.AssertError@std/container/slist.d(57): Assertion failure)
On Thursday, 13 August 2015 at 05:42:38 UTC, Freddy wrote:
I have a file that takes a while to compile with a static
interface. Is there any way i can make dub keep the object file
of only that file(for faster compilation)?
I don't think dub itself can do this, but
https://github.com/atilanev
42 matches
Mail list logo