Re: Dazz new description for D

2015-08-31 Thread Anthony Goins via Digitalmars-d

On Monday, 31 August 2015 at 07:38:18 UTC, Enamex wrote:
Some posters on reddit remarked that D's sales pitch on the 
website is unnecessarily long and unindicative.


I'm only making a suggestion; suggest others or comment on this 
one:


D is a multiparadigm systems programming language with 
excellent static introspection that lets you choose exactly 
what to pay for. D is a joy to write and easy to 
maintain: it's systems scripting with native 
performance.


Turned out too long :/


8) omg D ftw ;)


Re: Linux Dynamic Loading of shared libraries

2014-03-10 Thread Anthony Goins

On Monday, 10 March 2014 at 06:38:35 UTC, Steve Teale wrote:

On Sunday, 9 March 2014 at 14:09:28 UTC, Tolga Cakiroglu wrote:



For this, you create an Interface that matches to the method 
declaration of your class. But notice that instead of defining 
methods, you will define attributes those types' match to that 
class's methods. I did this before and it works. At least with 
Posix dlsym function's help.


OK, so then what goes wrong here:

module exta;

class ExtA
{
   int n;
   this(int _n) { n = _n; }

   int foo() { return ++n; }
}

ExtA getInstance(int n)
{
   return new ExtA(n);
}

compiled with:
dmd exta.d -c -fPIC -shared
dmd exta.o -shared -defaultlib=libphobos2.so -L-rpath=.

module main;
import core.runtime;
import std.stdio;

extern(C) void* dlsym(void*, const char*);
extern(C) void dlclose(void*);

interface ExtA
{
   int foo();
}

void main() {
   void* lib = Runtime.loadLibrary(exta.so);
   if (lib is null)
   {
  writeln(library not loaded);
  return;
   }
   writeln(loaded);

   void* vp = dlsym(lib, 
_D4exta11getInstanceFiZC4exta4ExtA\0.ptr);

   if (vp is null)
   {
  writeln(symbol not found);
  return;
   }
   writeln(got symbol);
   ExtA function(int) f = cast(ExtA function(int)) vp;
   ExtA x = f(42);
   if (x is null)
   {
  writeln(no class object);
  return;
   }
   int n = x.foo();
   writefln(n = %d, n);
   Runtime.unloadLibrary(lib);
}

compiled with:
dmd -c main.d
dmd main.o -L-ldl -defaultlib=libphobos2.so -L-rpath=.

output:
loaded
got symbol
n = 9
Segmentation fault (core dumped)

The answer should be 43. The segfault happens on the 
Runtime.unloadLibrary(lib); call.


Any ideas?

Steve


confusion between main.Exta and exta.ExtA
following worked for me

module exta;

import main;

//===
class ExtA : ExtA_IF
{
int n;
this(int _n) { n = _n; }

int foo() { return ++n; }
}

ExtA_IF getInstance(int n)
{
return new ExtA(n);
}
//=


//==
module main;
import core.runtime;
import std.stdio;

extern(C) void* dlsym(void*, const char*);
extern(C) void dlclose(void*);

interface ExtA_IF
{
int foo();
}

void main() {
void* lib = Runtime.loadLibrary(exta.so);
if (lib is null)
{
   writeln(library not loaded);
   return;
}
writeln(loaded);

//use extern (C) to avoid mangling
void* vp = dlsym(lib,
_D4exta11getInstanceFiZC4main7ExtA_IF\0.ptr);
if (vp is null)
{
   writeln(symbol not found);
   return;
}
writeln(got symbol);
ExtA_IF function(int) f = cast(ExtA_IF function(int)) vp;
ExtA_IF x = f(42);
if (x is null)
{
   writeln(no class object);
   return;
}
int n = x.foo();
writefln(n = %d, n);

// or free or destroy or whatever it's supposed to be to
//to avoid the seg fault  (bug?)
delete x;
Runtime.unloadLibrary(lib);
}


Re: Linux Dynamic Loading of shared libraries

2014-03-09 Thread Anthony Goins

On Sunday, 9 March 2014 at 12:07:22 UTC, Steve Teale wrote:

Martin Nowak's Gihub druntime Page has

module main;
import core.runtime, core.thread;

void main() {
auto lib = Runtime.loadLibrary(./liba.so);
auto thr = new Thread({
auto lib = Runtime.loadLibrary(./liba.so);
Runtime.unloadLibrary(lib);
});
thr.start();
thr.join();
Runtime.unloadLibrary(lib);
}

module liba;
import std.stdio;

shared static this() { writeln(shared static this()); }
shared static ~this() { writeln(shared static ~this()); }
static this() { writeln(static this()); }
static ~this() { writeln(static ~this()); }

Now suppose that my D shared library contains a class, rather 
that just module ctors/dtors, how do I go about creating an 
instance of that class and using its methods?


Steve

If you know the fully qualified name of the class and an interface
auto newClassIF = 
cast(interfacename)object.factory(libmodule.libclass);


Re: Start of dmd 2.064 beta program

2013-10-16 Thread Anthony Goins
On Wednesday, 16 October 2013 at 13:34:04 UTC, Andrej Mitrovic 
wrote:
On 10/16/13, Andrei Alexandrescu 
seewebsiteforem...@erdani.org wrote:

What are you protesting against?


Walter.


The last change log was awesome.
I vote to get rid of Walter. :)


Re: Problems importing core.sys.linux.epoll

2013-09-09 Thread Anthony Goins

On Monday, 9 September 2013 at 11:14:47 UTC, Mike Parker wrote:
I'm experimenting with some Linux stuff right now and am 
currently working on something using epoll. But I've run into 
an issue where dmd just doesn't see anything in 
core.sys.linux.epoll. As a workaround, I've implemented my own 
declarations for the bits I'm using. I'm curious, though, if 
anyone else has encountered this as I've never seen anything 
like it. I get no errors at all about it not being able to find 
the module, just things like epoll_event is undefined and 
such. If I try something like this:


import core.sys.linux.epoll : epoll_event;

Then I get an error about the import not being found. Other 
modules in core.sys.linux import just fine.


If anyone else can verify this same issue, I'll file a bug 
report. Otherwise, any ideas on what could cause this?


I get undefined identifier for everything in epoll.
DMD 2.63 (not latest) from debian download.


Re: ctRegex! vs regex error

2013-08-08 Thread Anthony Goins

On Wednesday, 7 August 2013 at 22:36:39 UTC, Milvakili wrote:

Hi,
I can compile

void main(){
auto myRegx = regex(`(?!test)`);
}

however can not compile this one

void main(){
auto myRegx =  ctRegex!(`(?!test)`);
}

code sample:http://dpaste.dzfl.pl/d38926f4

and get the following error:
...
std.regex.ctRegex!((?!test)) error instantiating


Sorry I really can't help you.
Except to let you know your code sample link is broken.


Re: I've started blog a little more about D.

2013-07-21 Thread Anthony Goins

On Saturday, 20 July 2013 at 21:19:03 UTC, Gary Willoughby wrote:
I'm starting to blog a little more and in particular i've 
started writing more about D. I'm using it a great deal at work 
now and all new stuff is to be written in it. I'm loving every 
minute of this and really want to sing its praises.


I'll not lie though, i still need to learn a great deal to be 
at the level of the engineers here but my sights are fully 
fixed on D and learning every aspect of it. I've already made a 
small contribution to druntime and i hope to do more.


I've finally got my head around templates and i've really 
started to understand their power and flexibility so i thought 
i would write an article as a one stop shop for other 
developers who need to understand this stuff as quickly as 
possible. I'd like for your verification that i have my facts 
straight and if not i'll amend the text asap.


Be gentle: http://nomad.so/2013/07/templates-in-d-explained/


Very nice thanks a heap.

Do not mind the Nay Sayers!  When a man needs to rebel he needs 
to rebel.
(But I must confess I'm a little spooked, thinking of Ayn Rand's 
Anthem.)


Re: interacting with a process with redirected stdin/stdout/stderr

2013-07-16 Thread Anthony Goins

On Monday, 15 July 2013 at 06:46:52 UTC, timotheecour wrote:

On Monday, 15 July 2013 at 03:49:10 UTC, Timothee Cour wrote:

I'm trying to interact with a process using std.process and
redirected stdin/stdout/stderr.
What would be the recommended way?

For example:

auto pipes=pipeShell(myprocess,Redirect.all);
while(true){
 pipes.stdin.rawWrite(some_command);
 foreach (line; pipes.stdout.byLine) {
   //do something with line
 }
}


This doesn't work because it might block inside 
pipes.stdout.byLine, as the
process is requesting more inputs to be written to its stdin 
before

outputting more bytes to its stdout.

What's the right approach?
* fcntl(fd, F_SETFL, O_NONBLOCK); didn't seem to work
* reading pipes.stdout inside a separate thread?
In that second case, how to cleanly dispose of a blocked 
thread when we no

longer need it?

Any detailed example would help.
Thanks!




I tried using a separate thread for reading the process' 
stdout. It works, except that sometimes the output is shuffled 
out of order.


Is there anything buggy in this:


__gshared string output;

void readBlocking(){
while ((c = fgetc(filepointer)) = 0)
  output~=cast(char) c;
//NOTE: i can use something more efficient here but that's 
beside the question

}

thread = new Thread( readBlocking);
output=null;
while(true){
Thread.sleep(...);
if(condition) break;
}
//now output is shuffled out of order sometimes


Furthermore, is there a standard way to tell when a process is 
waiting for stdin input ? (cf condition above). Currently I'm 
checking whether 'output' was modified within a timeout period 
T, but that's fragile and incurs of penalty of T at least.


Are you looking for select() or poll()
Poll I believe is posix only but I think select is more widely 
available.

Not much of an answer but I hope it helps



Re: Handling different types gracefully

2013-07-01 Thread Anthony Goins

On Monday, 1 July 2013 at 12:03:25 UTC, Roderick Gibson wrote:
I'm asking because I'm doing some game development in D and 
I've come upon the entity component architecture, and it looks 
like a good way to handle the complexity and interdependency 
that games seem to have.


The components wind up being plain old data types (I currently 
use structs), with systems that actually modify and interact 
with them on a per-entity basis. The basic idea is that you 
compose entities (basically just an id) with various components 
to give the specific functionality you need for that particular 
game object.


The whole entity system is just a database for the different 
subsystems to query for entities (just an id) which have 
components that fulfill their criteria (for example a physics 
subsystem might only be interested in entities with the 
components position, movement, and collision, while a render 
subsystem might only be interested in entities with components 
position, mesh, sprite). There's also the reverse where the 
subsystems register which components they are looking for and 
then the entity system serves up entities that match the 
criteria.


The standard way to store components is just to subclass them 
from a base class Component and then store a pointer to them 
in a Component[] in an overall entity manager. But then you 
have to do things like type casting the pointers when you 
return the queries, which seems a bit rough. It also feels 
wrong to make them inherit a class for the SOLE reason of 
getting around the type system.


Anyway, I think I'm just rubber ducking a bit here, but I'm 
wondering if there's another way to do this, if someone has any 
experience with this sort of system.


As an example of what I'm looking for, say there is a class 
Entities, with some type of container that could hold arrays of 
different component types (this is the part that really stumps 
me). I'd like to be able to do something like:


...
auto entities = new Entities();
auto entity_id = entities.createEntity();
entities.addComponent!(position)(entity_id, pos);
entities.addComponent!(movement)(entity_id, mov);
entities.addComponent!(collision)(entity_id, col);
auto physics_data = 
entities.getEntitiesWithComponents!(position, movement, 
collision)();


The two big requirements are some kind of regular, queryable 
structure to hold the components (of different types), and the 
ability to filter by type. Is anything like that remotely 
possible?


Waiting for multiple alias this ??
And opDispatch to respond to unimplemented components.


Re: Windows parameter

2013-06-30 Thread Anthony Goins

On Sunday, 30 June 2013 at 19:03:13 UTC, shuji wrote:

this code is in a .cpp file
//funcs.lib
//windows includes...
HWND hwnd;
int setHWND(HWND extHwnd){
hwnd = extHwnd;
return 0;
}

So im trying to import from D like this. I dont think I can 
implement this line in C++

extern (C++) {}


I'm probably the most unqualified person to offer help but are 
you sure you are linking with funcs.lib (assuming setHWND is 
defined there)


Cryptic Error message with scope(failure) and AA

2013-06-29 Thread Anthony Goins

Is this known?
I've heard there are many problems with associative arrays.

dmd 2.063

---
module scopefailtest;

int[char] AAarray;

void main(string[] args)
{
 AAarray = ['a':1, 'b':2, 'c':3];
 foreach(aa; AAarray)
 {
  scope(failure)continue;
  aa = 32;
 }
}
---

dmd output
Error: cannot implicitly convert expression (0) of type int to 
void



Works without scope(failure)
Works with non Associative Array

No helpful description.
No file or line number.
Very hard to find.


Re: Cryptic Error message with scope(failure) and AA

2013-06-29 Thread Anthony Goins




Seems like there are several levels of wrong actually: What 
do you expect scope(failure)continue to do exactly?




I was reading an array of files (Document[string]).
Stuck the scope(failure)continue in late at night apparently to 
skip reading files that no longer exist.

Forgot about it.  Still don't remember doing it.
Next day tried to build my project (30+ files).
I had no clue what was going on given the error message.

The problem for me was not the error itself but the message.

Thanks for the reply.
Didn't realize there was a problem with 'continue' from a 
scopeguard.




Re: indexing a tuple containing a struct strange result

2013-06-23 Thread Anthony Goins

On Monday, 24 June 2013 at 01:22:12 UTC, cal wrote:

What is going on here?

import std.stdio, std.typecons;

struct S
{
int x;
Tuple!(S) foo() { return tuple(this); }
}

void main()
{
S s;
s.x = 8;
writeln((s.foo())); //output: Tuple!(S)(S(8))
writeln((s.foo())[0]);  //output: S(0)
}


import std.stdio, std.typecons;

struct S
{
int x;
int y;
int z;

auto foo() { return tuple(this.tupleof); }
}

void main()
{
S s;
s.x = 8;
s.y = 9;
s.z = 10;
writeln((s.foo())); //output: Tuple!(int, int, int)(8, 9, 
10)


writeln(s.foo()[2]);  //output: 10
}

Is this what you expected?
I would explain what's going on but I'd be wrong.


Re: DConf 2013 Day 3 Talk 2: Code Analysis for D with AnalyzeD by Stefan Rohe

2013-06-12 Thread Anthony Goins
On Wednesday, 12 June 2013 at 12:50:39 UTC, Andrei Alexandrescu 
wrote:
Reddit: 
http://www.reddit.com/r/programming/comments/1g6x9g/dconf_2013_code_analysis_for_d_with_analyzed/


Hackernews: https://news.ycombinator.com/item?id=5867764

Twitter: 
https://twitter.com/D_Programming/status/344798127775182849


Facebook: 
https://www.facebook.com/dlang.org/posts/655927124420972


Youtube: http://youtube.com/watch?v=ph_uU7_QGY0

Please drive discussions on the social channels, they help D a 
lot.



Andrei


He mentions a D plug-in for sonar.
Is this available publicly?


Re: Don's talk's video to be online soon

2013-06-10 Thread Anthony Goins
On Monday, 10 June 2013 at 18:59:22 UTC, Andrei Alexandrescu 
wrote:
I'm experiencing trouble uploading the video of Don's talk, 
please bear with me. It will be available either later today or 
tomorrow morning.


Sorry,

Andrei


Will there be video for Andrew Edwards?


Re: about with statement

2013-06-10 Thread Anthony Goins

On Sunday, 9 June 2013 at 10:11:25 UTC, khurshid wrote:
D language have like Pascal/Delphi  with statement,  which 
very useful for writing readable code.


http://dlang.org/statement.html#WithStatement

Maybe I'm wrong, but, I never saw  where using this statement 
in phobos  source codes, what problem using this statement?


Regards,
Khurshid.


Am I the only one that found this useful?
Is there a better way?

with (specificModule)
{
result = ufcsChain.ambiguousFunction.link3();
}


Re: reddit discussion on replacing Python in 0install

2013-06-10 Thread Anthony Goins

On Monday, 10 June 2013 at 20:51:16 UTC, Jesse Phillips wrote:

On Monday, 10 June 2013 at 18:25:05 UTC, Graham Fawcett wrote:

Hi folks,

There's an interesting discussion going on at Reddit about 
choosing a replacement language for 0install:


http://www.reddit.com/r/programming/comments/1g1fhf/case_study_for_replacing_python_in_0install/

I've tried to do a bit of D advocacy there, but there's more 
to be done. :) If you have a few moments to dispel some D 
myths, and contribute constructively to the discussion, please 
take a look!


Best,
Graham


I don't know how to make this test on Windows (current OS). But 
he uses this to test that failure to print hello correctly 
indicates failure.


./hello 1 /dev/null; echo Exit status: $?

And Rust is the only one to pass in his list (ATS, C#, Go, 
Haskell, OCaml, Python)


If you want to know what happens on my linux box

  1 module hellotest;
  2
  3 import std.stdio;
  4
  5 void main()
  6 {
  7 writeln(hello world.);
  8 }

anthony@LinuxGen12:~/projects/temp$ ./hellotest
hello world.
anthony@LinuxGen12:~/projects/temp$ ./hellotest 1/dev/null; echo 
status : $?

status : 0
anthony@LinuxGen12:~/projects/temp$





-profile

2013-06-07 Thread Anthony Goins

Compiling with -profile and without -release
Gives the following error (not exactly but the best I can recall)
balancedParens is not nothrow  safe pure

With -release and -profile all is fine.
Builds fine without -profile.

Simple question is why?


Re: -profile

2013-06-07 Thread Anthony Goins

On Friday, 7 June 2013 at 21:39:26 UTC, bearophile wrote:

Anthony Goins:


Simple question is why?


I am compiling this code with -profile, and I don't see errors:


import std.string: balancedParens;
void main() {
assert(balancedParens([[]], '[', ']'));
}


Bye,
bearophile


okay found it

module profiletest;
import std.path;

void main()
{
assert(globMatch(foo.bar, *));
}

dmd -profile profiletest.d
/usr/include/dmd/phobos/std/path.d(2187): Error: balancedParens 
is not nothrow
/usr/include/dmd/phobos/std/path.d(2188): Error: balancedParens 
is not nothrow



globMatch is @safe pure nothrow
balancedParens is not nothrow
-release ignores contracts, right?



Re: -profile

2013-06-07 Thread Anthony Goins

On Friday, 7 June 2013 at 23:42:58 UTC, Anthony Goins wrote:

On Friday, 7 June 2013 at 21:39:26 UTC, bearophile wrote:

Anthony Goins:


Simple question is why?


I am compiling this code with -profile, and I don't see errors:


import std.string: balancedParens;
void main() {
   assert(balancedParens([[]], '[', ']'));
}


Bye,
bearophile


okay found it

module profiletest;
import std.path;

void main()
{
assert(globMatch(foo.bar, *));
}

dmd -profile profiletest.d
/usr/include/dmd/phobos/std/path.d(2187): Error: balancedParens 
is not nothrow
/usr/include/dmd/phobos/std/path.d(2188): Error: balancedParens 
is not nothrow



globMatch is @safe pure nothrow
balancedParens is not nothrow
-release ignores contracts, right?

 oops forgot to say
balancedParens is called from the 'in' contract of globMatch.
Is this even worth a bug report?


Re: -profile

2013-06-07 Thread Anthony Goins

On Friday, 7 June 2013 at 23:57:37 UTC, bearophile wrote:

Anthony Goins:


Is this even worth a bug report?


Yes, it's worth a bug report in Bugzilla, it's a (small) Phobos 
Bug. I confirmed its presence.


Bye,
bearophile


Thank you for all your help. Not just here but throughout the 
forums.

One more question though...

What is the error here :)
1. dmd profiletest.d
   should fail because balancedParens is not nothrow
   even though it is called from a contract.

2. dmd -profile profiletest.d
  should succeed because nothrow, @safe, pure don't apply to 
contracts


Re: Conditional compilation

2013-06-07 Thread Anthony Goins

On Friday, 7 June 2013 at 12:20:23 UTC, finalpatch wrote:

string mixins and template mixins don't work either.

On Friday, 7 June 2013 at 12:14:45 UTC, finalpatch wrote:

Hi folks,

I need to apply different calling conventions to the same 
interfaces when compiling for different platform. It's 
something like this:


OSX:

interface InterfaceA : IUnknown
{
extern(C):
   ...
}

Windows:

interface InterfaceA : IUnknown
{
   ...
}

I have to add extern(C) on OSX because apparently when the 
compiler sees IUnknown it automatically assumes the calling 
convention is extern(Windows) and in order to maintain 
compatibility with existing system I have to explicitly 
declare them as extern(C).


Now I have several dozens of interfaces like the above. I 
don't want to repeat them for OSX and Windows because the 
interface definitions are identical except the extern(C) line.


I have tried using version() like this:

interface InterfaceA : IUnknown {
   version(OSX)
   {
   extern(C):
   }
   ...methohds.
}

but it doesn't work because version limits the scope of the 
extern(C). static if has the same problem.


In C/C++ this is really easy, I can simply define a macro 
which expands to extern(C) on OSX and nothing on windows. Is 
there any way to achieve this in D without repeating the 
interface definitions?


string mixin will work

import std.stdio;
enum :string
{
 //define relevant functions in this string
 x1 =
 `void testfunc(string str)
 {
  writeln(str);
 }`
}


version(X)
{
 extern(C) mixin(x1);
 string str2 = c version;
}

version(Y)
{
 extern(Windows) mixin(x1);
 string str2 = windows version;
}

void main()
{
 testfunc(str2);
}

Yes it's ... well ... not very ... umm
But it works :)
extern(system) MIGHT be a better option.


non-standard json output

2013-06-04 Thread Anthony Goins

Is this a bug?

file : /home/anthony/projects/dcomposer/src/printui.d,

A line from DMD 2.063 json output.

file : \/usr\/include\/d\/gsv\/SourceBuffer.d,

A line from an older DMD version. Forward slashes escaped 
according to json standard.


Hesitant to file a bug report because by the time I see something 
it's probably already well known and fixed.






Re: non-standard json output

2013-06-04 Thread Anthony Goins

On Tuesday, 4 June 2013 at 21:35:27 UTC, Brian Schott wrote:

On Tuesday, 4 June 2013 at 20:59:55 UTC, Anthony Goins wrote:

Is this a bug?

file : /home/anthony/projects/dcomposer/src/printui.d,

A line from DMD 2.063 json output.

file : \/usr\/include\/d\/gsv\/SourceBuffer.d,

A line from an older DMD version. Forward slashes escaped 
according to json standard.


Hesitant to file a bug report because by the time I see 
something it's probably already well known and fixed.


Where does the standard say that forward slashes have to be 
escaped? It shows in the syntax diagram that you CAN escape it, 
but there is no requirement to do so as it is a unicode 
character other than '' or '\'


any-Unicode-character-
except--or-\-or-
control-character
\
\\
\/
\b
\f
\n
\r
\t
\u four-hex-digits

from http://www.json.org/;


Re: non-standard json output

2013-06-04 Thread Anthony Goins

On Tuesday, 4 June 2013 at 21:35:27 UTC, Brian Schott wrote:

On Tuesday, 4 June 2013 at 20:59:55 UTC, Anthony Goins wrote:

Is this a bug?

file : /home/anthony/projects/dcomposer/src/printui.d,

A line from DMD 2.063 json output.

file : \/usr\/include\/d\/gsv\/SourceBuffer.d,

A line from an older DMD version. Forward slashes escaped 
according to json standard.


Hesitant to file a bug report because by the time I see 
something it's probably already well known and fixed.


Where does the standard say that forward slashes have to be 
escaped? It shows in the syntax diagram that you CAN escape it, 
but there is no requirement to do so as it is a unicode 
character other than '' or '\'


Thanks, I get it now.


Re: non-standard json output

2013-06-04 Thread Anthony Goins

On Tuesday, 4 June 2013 at 21:55:38 UTC, Brian Schott wrote:
The char rule in the json standard can be matched by anything 
that isn't a control character, a double quote, or a backslash. 
I'm pretty sure you're not arguing that the forward slash is a 
double quote or that the forward slash is a backslash, so the 
only option left is that '/' is a control character, and thus 
needs escaping. I'm pretty sure that it's not, because 002f is 
not in the range defined as a control character[1]


[1] http://www.unicode.org/glossary/#control_codes


I appreciate your taking time to enlighten me.
I almost get it.
b is b
\b is backspace
f is f
\f is formfeed
/ is /
but what the heck is \/

This is a rhetorical post.
Go back to being productive ;)


Re: DMD 2.063 produces broken binaries

2013-06-04 Thread Anthony Goins

On Tuesday, 4 June 2013 at 18:03:53 UTC, Jerry wrote:

Hi folks,

I've downloaded the current dmd 2.063 zip and tried it out.  
This is
Ubuntu 12.10 x86_64.  Every program I compile segfaults when I 
try to

run it.  As a simple example:

jlquinn@wyvern:~/re/test$ cat junk.d
import std.stdio;
void main() {
  writeln(Hi);
}
jlquinn@wyvern:~/re/test$ /home/jlquinn/dmd2/linux/bin64/dmd 
junk.d

jlquinn@wyvern:~/re/test$ ./junk
Segmentation fault (core dumped)

The gdb backtrace is somewhere in __libc_start_main, before 
main() is

run.

I assume I'm not in the majority, but I literally can't compile 
and run

anything.

Any help would be appreciated
Thanks
Jerry


Similar problem, you aren't alone.  Poster noticed the segfaults 
after installing gdc.


http://forum.dlang.org/post/mailman.573.1370076049.13711.digitalmars-d-le...@puremagic.com



Re: how to use shared keyword in 2.063 version?

2013-05-31 Thread Anthony Goins

On Friday, 31 May 2013 at 21:01:49 UTC, Andrey wrote:

Hello!

I'm trying to use following code:

==
//...

class A
{
private
{
int m_someVar = 10;
}

public
{
this()
{
}
}
}


int main(string[] args)
{
shared A a = null;
a = new shared(A)(); // error.

return 0;
}
==

And on compile time, the compiler says Error: non-shared 
method main.A.this is not callable using a shared object.
How can I use an objects as shared, which classes were not 
defined with synchronized or shared keyword?



Thanks.


To create a shared object you need shared this ctor.

immutable this() for immutable,

and const this() for const.

Check out the change log.  #2 on the list.


Re: Segfault on simple program?

2013-05-31 Thread Anthony Goins

On Friday, 31 May 2013 at 17:14:46 UTC, Shriramana Sharma wrote:

import std.stdio ;

void foo ( int[] array ) {
foreach ( i ; array ) { writeln ( i ) ; }
}

void main () {
foo ( [ 1, 2, 3 ] ) ;
}

On both DMD 2.062 and 2.063 this compiles OK but causes a 
segfault.

I'm running Kubuntu Raring 64-bit. Any hints?


Works for me ubuntu 64.

Do you have both versions installed?
Would it compile if you used the wrong druntime / phobos 
libraries?


Re: Failed to sort range

2013-05-28 Thread Anthony Goins

On Tuesday, 28 May 2013 at 12:57:12 UTC, Sergei Nosov wrote:

Hi!

I'm trying to implement an array, which uses malloc to allocate 
memory. Also, I want to implement a random access range 
interface for it.


That went pretty well, until I tried to sort it. Sorting 
function asserted Failed to sort range of type Array!(int).


I've spent quite some time trying to figure out what's going on 
with no success.


The implementation can be found at:
https://gist.github.com/snosov1/5662471

I used
DMD64 D Compiler v2.062 and
LDC - the LLVM D compiler (trunk): based on DMD v2.062 and LLVM 
3.2svn
on Ubuntu. Phobos version was the one that came with the dmd 
compiler.


Does anyone have any ideas what's wrong with the code I've 
provided?


sort!(ab, SwapStrategy.stable)(arr);

This worked for me with the code at your link.
Of course it does not answer your real question.
But it is a place to start looking.
(assuming you aren't miles ahead of me already.)