Re: Is D a good choice for embedding python/octave/julia
On 03/13/2016 02:36 PM, Laeeth Isharc wrote: InterpContext context = new InterpContext(); context.py_stmts(outdent(" import numpy a = numpy.eye(2, dtype='complex128') ")); context.a.to_d!(Complex!double[][] )(); nitpicking, but the outdent is unnecessary, py_stmts calls it. hm. maybe that should be documented..
Re: Calling python code from D
On Thursday, 25 February 2016 at 21:40:45 UTC, Wyatt wrote: I have a project I started in Python before I realised I really don't enjoy Python. It's been on the back-burner for a few years and I'd like to start again in D, but there's a particular python module (Mutagen) that I outright refuse to reimplement. What's the state of the art in calling Python code from D? I have a hunch PyD fits somewhere in this equation, but the documentation is pretty sparse, and what little I can find about this area makes it seem like a fairly tedious manual process. Is there a less-painful and intensive way to truss things up? Something to generate a simple D wrapper from a python module? -Wyatt If you want to call python from D, you should be able to install pyd with dub. Depending on your python setup, it should Just Work. If python is set up weird (ubuntu), you will need to generate some custom dub config and insert it in your dub.json. look for generate_dub_config.py on github for the generation part. or install pyd with pip and run python -m pyd.generate_dub_config after that, you should be good to go. some example usage off the top of my head that probably doesn't compile: py_init(); InterpContext context = new InterpContext(); context.pystmts(` from mutagen.flac import FLAC audio = FLAC("example.flac") audio["title"] = "An example" `); auto audio = context.audio; audio.pprint(); audio.save();
Re: Future(s) for D.
On 06/20/2015 07:00 AM, Etienne wrote: On Saturday, 20 June 2015 at 13:33:34 UTC, Dragos Carp wrote: On Saturday, 20 June 2015 at 12:35:11 UTC, weaselcat wrote: I recently read this facebook post on their future implementation in their Folly library. https://code.facebook.com/posts/1661982097368498 This made me slightly envious. Thoughts on a D implementation? Even if the callbacks are sequentially listed, the callback hell is still there. A better solution is to use fibers. You can take a look at a fibers[1] and tasks[2] implementation in asynchronous library[3]. [1] - https://github.com/dcarp/asynchronous/blob/master/src/asynchronous/futures.d [2] - https://github.com/dcarp/asynchronous/blob/master/src/asynchronous/tasks.d [3] - http://code.dlang.org/packages/asynchronous Yep, looks like we already have better. I don't understand how D hasn't fully picked up in Web Dev at this point. Are they expecting an e-commerce/blogging/cms platform to go with it? A while back I was bored and curious to see how vibe would fare in the web framework benchmarks (http://www.techempower.com/benchmarks/) so I started adding vibe to it (https://github.com/ariovistus/FrameworkBenchmarks). Chose to go with ddb. Postgresql+asynchronous, sounds great. It didn't compile with the latest dmd at the time. So I fixed it up, made a PR, and it worked fine. It looked like I was getting results close to netty (in json serialization) without much effort, but ultimately, I set it aside to wait for my PR to be merged. what is the deal with ddb, anyways? Is it dead?
Re: Dlang seems like java now,but why not let d more like C# Style?
On Sunday, 15 March 2015 at 14:58:54 UTC, Idan Arye wrote: Even if we can't get the lambdas as syntax tress, the fact that we can send whatever types we want to the delegates and overload operators and stuff means we can still convert the lambdas into SQL. There are limitations on operator overloading that make it much less likely you can use the exact same lambdas for collections and sql. Bad for testability. At any rate, I really don't like what C# did with LINQ-to-SQL. The whole special-syntax to functional-style to syntax-tree to SQL is too overcomplicated - a simply lisp-style macro system(like what they have in Scala or Rust) could have done the trick in a simpler and faster way. overcomplicated? probably - it's microsoft. And any time I have to manipulate the ASTs I find myself wishing for a language with pattern matching. I wonder if F# offers anything in that regards..
Re: Dlang seems like java now,but why not let d more like C# Style?
On Saturday, 14 March 2015 at 23:57:33 UTC, weaselcat wrote: On Saturday, 14 March 2015 at 23:46:28 UTC, Ellery Newcomer wrote: And C# has LINQ, which when combined with the last point is fricken awesome. what does LINQ offer that UFCS-style functional programming does not? LINQ basically is a UFCS-style api. AST reflection is what makes it nice. consider: X.Where(x = x.Members.Count() == x.Admins.Count()) straightforward in both D and C# when X is an array or container type. When X is a table in a database, things get tricky for D. C# can interpret the lambda as an ExpressionFunc (an AST type), so the implementation of X can reflect over the body of the lambda and use it to generate the appropriate SQL. ORMs such as entity framework and nhibernate do this now.
Re: Dlang seems like java now,but why not let d more like C# Style?
On Saturday, 14 March 2015 at 13:52:13 UTC, Craig Dillabaugh wrote: I don't have any C# experience so I can't compare those languages much, but I've heard people say their are D / C# similarities. Anyway, this isn't a criticism of your comment, I was just curious what (other than the shared C++ syntax heritage) you find so Java-like in D? Cheers, Craig I've been using C# pretty extensively for the last year or so. Superficially, at least, C# and D are pretty similar, eg auto (var), foreach, lambdas, classes and structs. C# is more biased towards OO than D. Metaprogramming is significantly weaker in C#. This is probably the one area where I've wished for some of D's functionality. Reflection is all runtime. C# has some AST capabilities that D doesn't. This is probably the main area where I envy C# when using D. And C# has LINQ, which when combined with the last point is fricken awesome.
Re: embedding Pyd in Windows program
On Saturday, 14 March 2015 at 07:28:04 UTC, Matt wrote: Yeah, dub is what I'm using. Actually, I made a mistake regarding the py_eval. I'm including the pyd modules in a module other than the one that has my main() function, so they weren't visible. I feel like a proper idiot for that one.. So I set up a separate project to test the samples exactly. The simple_embedded sample seems to work no problem. I haven't gotten round to trying the shared_embedded, yet, but I will do at some point. Does pyd have any documentation, or are we working from the source for understanding the functions? there is readthedocs: http://pyd.readthedocs.org/en/latest/ there is [old] ddoc: http://ariovistus.bitbucket.org/index.html which I've been meaning to figure out how to get into readthedocs. there is a confluence space: https://pythond.atlassian.net/wiki/display/pyd/pyd+Home where I occasionally log tidbits that might be of value
Re: embedding Pyd in Windows program
On Friday, 13 March 2015 at 19:05:59 UTC, Matt wrote: example code, see if I can figure it out, but if you can advise, that would be fantastic. Thank you for all the help so far, it's really been appreciated My penitence for not putting this information on readthedocs. I've tried the hello.d example from GitHub, and get the error message: Error: template instance py_eval!string template 'py_eval' is not defined Unfortunately, that's all I seem to get. Is py_eval not deprecated in 0.9.4? hmm. that's odd. are you trying to build with dub? the only examples that build with dub are in examples/dub. the rest use distutils.
Re: embedding Pyd in Windows program
On Friday, 13 March 2015 at 09:38:45 UTC, Matt wrote: I used the ~0.9.4 branch in dub, and I'm not sure how to change configuration. Do you mean I should be using ~master or ~develop? nope. configurations are a different thing. you can set them in your project's dub.json. example: https://github.com/ariovistus/pyd/blob/master/examples/dub/simple_embedded/dub.json for your project, I think you'd want subConfigurations: { pyd: python34, } as for the transferring the python3.dll, I downloaded and installed a fresh copy of the latest Python build, version 3.4, and copied the libraries from there. Even so, I had to add PYD_PACKAGE_DIR manually to get it to work. PYD_PACKAGE_DIR is necessary for linking the OMF files found in infrastructure/windows. hmm. why did it not Just Work? I'm not sure I'm going to be able to run the python snippet you sent, since my program, which currently opens a window for three seconds before closing again, doesn't even get that far, and chokes when I run py_init(). you can put it in the top of site.py
Re: embedding Pyd in Windows program
On 03/11/2015 07:59 PM, Matt wrote: Right, copying site.py into my program's working dir sorts out the missing module error, but I now get a syntax error: file=sys.stderr) ^ SyntaxError: invalid syntax Error executing command run: Program exited with code 1 I googled this, and apparently it's caused by an older interpreter. The only files I have transferred over are: python3.DLL python3.LIB python34.LIB Does anyone have any idea what I might be doing wrong, or how I can fix this? I'm guessing your python path is screwed up. In your embedded python, import sys print (sys.path) make sure everything is pointing where it should. Failing that, are you using the correct dub configuration? without checking, I believe it defaults to python 2.7. Failing that, you transferred python3.dll from somewhere to somewhere? I believe pyd links to \windows\system32\python3.dll or some such. At least, I think that's where those lib files point to. not sure. If that is an issue and you want to use your own lib files, you will need to generate OMF files from them.
Re: PyD-like wrapping for Excel/VBA and Julia?
On 12/18/2014 12:41 PM, Laeeth Isharc wrote: I have a bunch of D functions I would like to make available to Excel (and possibly Julia) without having to write wrappers for each function individually. I've thought about refactoring the reflection parts of pyd into a reusable library for e.g. resurrecting RuD. Come to think of it, that would probably be necessary for supporting pypy. It'd be a heck of a lot of work, though. For your wrapper, you can probably do something like extern(Windows) double vbwrap_test(double* inp,size_t num_inp,double* oup,size_t num_oup) { return test(inp[0 .. num_inp], arg_oup[0 .. num_oup]); } with .dup sprinkled in as you see fit. And you don't need to explicitly copy the results back! Might need to take the ref off oup in test..
Re: threading issues with D - C - Python
On 12/07/2014 03:12 PM, Michael wrote: now to figure out how to use them in the general case. This is great.. Thank you. I'm looking forward to being able to try the finished result. My build servers are broken at the moment, but I think I have this fixed, on linux at least.
Re: detaching a thread from druntime 2.067
On 12/16/2014 10:41 AM, Sean Kelly wrote: On Tuesday, 16 December 2014 at 04:56:10 UTC, Ellery Newcomer wrote: If I have a thread that I need to detach from druntime, I can call thread_detachInstance, but for 2.066, this function does not exist. Is there any way to do this in 2.066? I notice there is a thread_detachByAddr, but I'm not sure how to get a ThreadAddr out of a Thread.. thread_detachThis? the thread I want to detach isn't currently running.
Re: Travis-CI support for D
On 12/14/2014 03:03 PM, Ellery Newcomer wrote: On 12/10/2014 08:50 PM, Martin Nowak wrote: Glad to announce that D support on Travis-CI was launched today. http://blog.travis-ci.com/2014-12-10-community-driven-language-support-comes-to-travis-ci/ trying it out with pyd, and I'm getting ImportError: libphobos2.so.0.66: cannot open shared object file: No such file or directory are shared libraries supported? .. I'll take that as a no, then.
detaching a thread from druntime 2.067
If I have a thread that I need to detach from druntime, I can call thread_detachInstance, but for 2.066, this function does not exist. Is there any way to do this in 2.066? I notice there is a thread_detachByAddr, but I'm not sure how to get a ThreadAddr out of a Thread..
Re: Travis-CI support for D
On 12/10/2014 08:50 PM, Martin Nowak wrote: Glad to announce that D support on Travis-CI was launched today. http://blog.travis-ci.com/2014-12-10-community-driven-language-support-comes-to-travis-ci/ trying it out with pyd, and I'm getting ImportError: libphobos2.so.0.66: cannot open shared object file: No such file or directory are shared libraries supported?
Re: Travis-CI support for D
On 12/10/2014 08:50 PM, Martin Nowak wrote: Glad to announce that D support on Travis-CI was launched today. I'm a noob when it comes to travis, so it isn't readily apparent to me, but given this, would travis support a build that installs a d compiler and also some version of python?
Re: threading issues with D - C - Python
On 12/07/2014 03:12 PM, Michael wrote: On Saturday, 6 December 2014 at 00:40:49 UTC, Ellery Newcomer wrote: On 12/04/2014 10:55 PM, Ellery Newcomer wrote: I guess tomorrow I can try messing around with thread_attachThis, as the fullcollect happening in #2 might be screwing with python data. But you aren't really passing anything from python to d or vice versa, so I'm not sure why the gc would need to know about the python threads. by gum, thread_attachThis and thread_detachThis fix the issue! now to figure out how to use them in the general case. This is great.. Thank you. I'm looking forward to being able to try the finished result. It would be great if there were some convenient hook in python to stick these calls. Near as I can tell, there isn't. That leaves you with either explicitly calling attach and detach with an exposed api, or pyd obsessively checking whether the current thread is registered. Actually, I suppose with a thread local flag the latter wouldn't be too bad. Mind if I incorporate your example into pyd's test suite?
Re: threading issues with D - C - Python
On 12/04/2014 10:55 PM, Ellery Newcomer wrote: I guess tomorrow I can try messing around with thread_attachThis, as the fullcollect happening in #2 might be screwing with python data. But you aren't really passing anything from python to d or vice versa, so I'm not sure why the gc would need to know about the python threads. by gum, thread_attachThis and thread_detachThis fix the issue! now to figure out how to use them in the general case.
Re: threading issues with D - C - Python
On 12/04/2014 02:11 PM, Michael wrote: On Thursday, 4 December 2014 at 03:22:05 UTC, Ellery Newcomer wrote: dustmite? Not sure what went wrong with dustmite, but every time I tried it it just started deleting all the files in the directory and setup.py would give errors. I manually deleted a reasonable chunk of the code and I'm left with these files which still seem to cause segfaults: Main code: http://pastebin.com/zqgNTk9w PyD definitions: http://pastebin.com/6mRH3KZZ setup.py: http://pastebin.com/i9Ph78UC test code that causes segfaults: http://pastebin.com/1ukzShVh Cheers, Michael. hmm.. looks like here it originates in python when it tries to acquire the GIL. specifically, pthread_cond_timedwait is segfaulting. in your code, execution inside a python thread makes it to receiveTimeout in get_image. it made it past receiveTimeout in acquire. then I guess there is a context switch. the main python thread throws an exception, but a number of things trigger the segfault. I think it's just the interpreter loop calling RestoreThread. backtrace looks like #0 pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:238 #1 0x003799d07bb3 in PyCOND_TIMEDWAIT (cond=0x379a063220 gil_cond, mut=0x379a0631e0 gil_mutex, us=5000) at /usr/src/debug/Python-3.3.2/Python/condvar.h:103 #2 take_gil (tstate=tstate@entry=0x604410) at /usr/src/debug/Python-3.3.2/Python/ceval_gil.h:224 #3 0x003799d081fb in PyEval_RestoreThread (tstate=tstate@entry=0x604410) ... It looks like this is the python main thread. I see two other threads. (i took out one of your python spawns) #2 looks to be your listener thread. std.concurrency.send seems to have gotten it into a gc_malloc, but it looks like it's just waiting. it's currently in sem_wait. this one would have been spawned in D code by #3 #3 is your other python thread. it is also in pthread_cond_timedwait. by its stack trace, receiveTimeout is just waiting. I guess tomorrow I can try messing around with thread_attachThis, as the fullcollect happening in #2 might be screwing with python data. But you aren't really passing anything from python to d or vice versa, so I'm not sure why the gc would need to know about the python threads. not exactly my area of expertise, this.
Re: threading issues with D - C - Python
On 12/03/2014 04:43 PM, Michael wrote: On Wednesday, 3 December 2014 at 21:35:48 UTC, ketmar via Digitalmars-d-learn wrote: ah, dsource strikes back! that vile site keep biting us again and again. let's hope that new admins will kill it for good. Yeah. I've got the new PyD and it compiles and does everything I want much nicer, but it appears to have the exact same problems. When calling a python thread to my code, it can cause segfaults and hanging issues. Cheers, Michael. okay. that's not too surprising. If you can get me a minimal example, I'd be happy to have a look since pyd should probably support this case.
Re: threading issues with D - C - Python
On 12/03/2014 06:56 PM, Michael wrote: On Thursday, 4 December 2014 at 02:31:51 UTC, Ellery Newcomer wrote: okay. that's not too surprising. If you can get me a minimal example, I'd be happy to have a look since pyd should probably support this case. Cool. Unfortunately most of the times I've attempted to reduce this down it always seems to work, but I think that's because I often did the example code in D. I'll play around with it and try to send you an example. Cheers, Michael. dustmite?
Re: threading issues with D - C - Python
On 12/02/2014 05:07 PM, Michael wrote: Hi. I'm new here and this is my first post. I'm not sure this is the right subforum for it, but wasn't sure where else to put it either. I've written a library to talk to some external hardware using a socket. It uses the std.concurrency threads to send messages between the main D-object for the hardware and the D-object for the sockets. I then wanted to be able to call these functions from Python. PyD appeared to be out of date, so I've been using a D - C interface, and a C - Python interface. The python code will often run from different python threads, so I then added yet another message-passing layer between the D-C interface and the D-hardware interface. are you looking at this pyd: https://bitbucket.org/ariovistus/pyd
Re: building shared library from D code to import into cython
On Sunday, 12 October 2014 at 16:07:19 UTC, Laeeth Isharc wrote: Any thoughts on speed in 2014 of pyd vs using cython to talk to D directly via C/C++ interface? I saw this old coment here: pyd is basically just a convenience layer on top of the C interface. The part that would most likely screw with performance would be conversion from D objects to python objects and vice versa since that normally does a value copy. At the time of that comment, pyd's strategy for arrays was just iterate and convert each element. Now pyd can take advantage of the buffer protocol if it is exposed (2.7+), so converting e.g. numpy arrays should be just a memcopy. If you want by ref semantics instead of by value, use PydObject instead of a D type in your function signature. You can also turn off all conveniences and just use the C api with raw_only (https://bitbucket.org/ariovistus/pyd/wiki/CeleriD)
Re: building shared library from D code to import into cython
On Wednesday, 8 October 2014 at 00:25:57 UTC, Laeeth Isharc wrote: Hi. Thanks for the quick response. The -defaultlib was left around from trying all kinds of combinations of dmd and gcc. I am not used to gcc, and it will take me some time to become properly acquainted with all the options. I managed to get it to compile with default dmd rpm: https://github.com/ariovistus/cythonic_d fedora 20, x86_64 Are you aware of pyd? (https://bitbucket.org/ariovistus/pyd) It knows how to build shared libraries, so I recommend you play with it, if only to watch how it does that. Biggest gotcha is starting up druntime.
how to tell if a thing is a template
Can't think off the top of my head how you do this template IsTemplate(alias t) { ?? } static assert(IsTemplate!IsTemplate)
Re: Something like Python's psutils for D?
On Saturday, 12 July 2014 at 08:34:41 UTC, Thomas Mader wrote: The Subject says it all, is something like psutils available in D? would psutils itself be acceptable? https://bitbucket.org/ariovistus/pyd
Re: readln for tango with d2?
On Monday, 23 June 2014 at 10:52:32 UTC, seany wrote: Doese tango come with a readline fucntion for d2? from this site, i was unable to find anything in my search : http://siegelord.github.io/Tango-D2/ tango.io.Console, maybe?
Re: C++'s defaulted comparison operators proposal
On Wednesday, 18 June 2014 at 05:49:30 UTC, Ali Çehreli wrote: Can you come up with a D library solution to the following C++11 proposal: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n3950.html did this years ago (or something similar, at least): https://bitbucket.org/ariovistus/multi_index/src/0993f8604c1438f6d9f26f580939b42fdd159a67/src/multi_index.d?at=default#cl-4654 example: https://bitbucket.org/ariovistus/multi_index/src/0993f8604c1438f6d9f26f580939b42fdd159a67/unittests/multi_compare.d?at=default
Re: pyd - continuous integration
On Tuesday, 10 June 2014 at 14:39:25 UTC, Atila Neves wrote: If you can spare the time / HW resources, I'd probably go with Vagrant and Buildbot, but then again I would since I'm familiar with both. Atila I stumbled on vagrant a few months ago but haven't had a chance to play with it yet. I take it you need a pretty beefy box to use it? Another thing I was envisioning is a web page that shows test results for each combination so that it is easy for a casual user to determine pyd's status. Does buildbot have this sort of thing?
pyd - continuous integration
So pyd is at the point where it really needs some sort of test suite runner. It's kind of complicated since I need to test against * multiple versions of dmd/ldc/gdc * multiple versions of python (2.4 - 3.4, but I'm thinking of dropping 2.4 and 2.5 this year) * redhat, ubuntu, osx, windows, etc Does anyone have any suggestions on how or where to set this up? I had a peek at atlassian bamboo, but it looks like it only plays with ec2, which I don't know anything about.
Re: Fedora DMD package
On Friday, 6 June 2014 at 15:24:20 UTC, Russel Winder via Digitalmars-d wrote: OK, I can perhaps see why glibc-devel, but the rest? And why i686 packages on an x86_64 machine? Thanks. to support -m32, probably
cannot allocate memory in static TLS block
I have a ubuntu 12.04 spin in which I am running dmd hello.d -shared -defaultlib=libphobos2.so -ofhello.so on an empty hello.d. attempting to use it (python) results in Traceback (most recent call last): File test.py, line 1, in module import hello ImportError: /usr/lib/i386-linux-gnu/libphobos2.so.0.65: cannot allocate memory in static TLS block anyone else seeing this? dmd 2.065, deb package from dlang.org.
Re: Linking with C on Windows
On Thursday, 5 June 2014 at 23:12:56 UTC, Mark Isaacson wrote: I need to eventually be able to export a dll that can talk with anything. how would using dmc conflict with this goal? dmd/dmc output omf object files, windows infrastructure is all coff object files. linux/mingw/etc are.. something else.. your options are 1. use dmd/dmc, and if you need to link to windows api dlls or others, use coffimplib (here - ftp://ftp.dlang.org/) to convert the appropriate lib files. 2. if you can stomach the loss of generality, use dmd -m64, which does output coff object files and go your merry way with vc++. (I don't do this, so don't quote me on this) 3. use the mingw builds of ldc/gcc (I don't do this either and can't comment on how much fun you'll have getting dlls out of them/linking to other dlls)
Re: Using D static library from C
On Thursday, 5 June 2014 at 18:51:25 UTC, George Sapkin wrote: I'm trying to link a simple D static library to C code, but I'm can't figure out how to do it properly without getting a segfault when running it. try this: dmd -lib test.d -defaultlib=libphobos2.a -oflibtest.a gcc main.c libtest.a -l:libphobos2.a -lpthread -lm -lrt
Re: Using D static library from C
On Friday, 6 June 2014 at 02:17:50 UTC, George Sapkin wrote: On Friday, 6 June 2014 at 02:13:08 UTC, Ellery Newcomer wrote: On Thursday, 5 June 2014 at 18:51:25 UTC, George Sapkin wrote: I'm trying to link a simple D static library to C code, but I'm can't figure out how to do it properly without getting a segfault when running it. try this: dmd -lib test.d -defaultlib=libphobos2.a -oflibtest.a gcc main.c libtest.a -l:libphobos2.a -lpthread -lm -lrt Awesome! That works! Thanks. So is dmd linking to shared/different phobos2 by default or something? yeah, -defaultlib=libphobos2.so is the other option, I guess it's default now.
Re: dxl (the d port of jexcelapi)
On Thursday, 8 May 2014 at 20:57:08 UTC, Taylor Hillegeist wrote: So i was thinking i wonder if anyone has a d library for excel and behold there it was. however, it seems like d has grown since this was written. I'm getting bunches of errors telling me that i can't override a function without the override keyword. which is not a big deal, however I seem to be missing libraries. std.date; cannot be found :( is this equivalent to std.datetime? dcollections.LinkList; I found it but should i use It? is there not something in std.containers; that would replace it? Last I used std.containers (which admittedly has been a few years), I developed a pretty deep distrust of DList. Personally, I would use multi_index, but you are probably better off sticking with dcollections. unless steve hasn't been maintaining it.. Also, I'm the author/porter of dxl. I think I quit maintaining it because I was waiting for the new io api, which I guess still hasn't happened. I don't really have time to work on it right now, but if you have questions, feel free to ask.
string - string literal
is there a function in phobos anywhere that takes a string and escapes it into a string literal suitable for string mixins? something like assert (f(abc\ndef) == \abc\\ndef\);
on interfacing w/C++
(Putting this out there because it sounds like I'm going to get scooped in the near future) So last week I was dinking around with the idea of a library to support calling C++ functions. So I wrote some ct code to emulate g++ 4.8.2's mangling scheme, and wrote a bit more code to wrap it, and calling conventions seemed to work out, and this is what I got: for the C++: class X { public: int i; X(); int y(); void z(int j); static int abu(int j); }; do this: mixin CppClass!(X, typeof(new class { int i; int y(); void z(int j); static int abu(int j); })); mixin(X.Externs); // waa, issue 12575 it generates something like struct X { int i; int y() { return _ZN1X1yEv(this); } void z(int j) { _ZN1X1zEi(this, j); } static int abu(int j) { return _ZN1X3abuEi(j); } } extern(C) int _ZN1X1yEv(X*); extern(C) void _ZN1X1zEi(X*,int); extern(C) int _ZN1X3abuEi(int); And it all seems to work. pointer params, reference params, variadic params, operators, templates all seem within ready reach. virtual functions are going to be difficult - I guess you'd have to have a complete and accurate list of all fields in the class and all its superclasses. And all virtual functions. But g++ inserts a vtable symbol for classes with virtual functions - does anyone know what the heck that is? Same for constructing a C++ object from within D - you need a valid sizeof. other compilers won't work as above, the mangling scheme used by eg DMC doesn't produce valid D identifiers. Is there a pragma or anything to get around this? And I totally spaced on exceptions until I looked on this forum a few minutes ago. So my plan is to get all these bits implemented, then build a tool to validate the C++ and D sides match up, then build a tool to generate the D side from C++ headers. And then start expanding the list of supported C++ compilers. Does this sound like a reasonable project? The points of concern I am worried about most are: safety associated with supporting virtual functions if a c++ mangler is stateful, that would shut me down pretty quick. it requires the C++ compiler/version be specified at a library level exceptions probably won't work
Re: GDC ARM beta #1 (with binary releases!)
On Monday, 17 March 2014 at 14:07:13 UTC, Johannes Pfau wrote: I'm happy to announce the first GDC ARM beta on behalf of the GDC team :) Cool! Just tried building it with crosstools-ng on my poor old laptop, and 90 minutes in it gives me /home/ellery/Downloads/pitools/.build/src/gcc-custom/libphobos/libdruntime/core/threadasm.S:387: Error: selected processor does not support ARM mode `vpop {d8-d15}' Any thoughts? My guesses are 1. set Default Instruction Set to thumb (?) or 2. the submodules didn't update on git pull. But I've gotten a working compiler out of this config before, from Mr. Pfau's fork a few months ago, so prolly not 1. I'd test these myself, but I don't have a spare 180 minutes tonight.. gdc-4.8 branch; gcc-4.8.1, should be the linaro source, but not sure
Re: Interface D with other languages
On Wednesday, 26 March 2014 at 14:52:56 UTC, Andrea Fontana wrote: This seems to be a D - python ! https://bitbucket.org/ariovistus/pyd a D - python even! annotations would be a nifty enhancement, something like @python_expose class Foo { @python_expose public void bar() { } // no expose public Fizz baz() { } } maybe?
Re: Python calling D
On Tuesday, 4 February 2014 at 16:17:30 UTC, Russel Winder wrote: On Tue, 2014-02-04 at 12:45 +, Artem Tarasov wrote: But it does lead to a working system :-) Any particular reason you aren't using CeleriD to build this shared lib? CeleriD uses some hooks to call rt_init when the library loads. https://bitbucket.org/ariovistus/pyd/src/92b9962b429ed33afa7048cf1923fd76d0fe8977/infrastructure/d/?at=default see so_ctor.c and python_so_linux_boilerplate.d Also, note however you do it, if you have multiple shared libs, don't call initialize/term more than once. segfaults happen.
Re: Python calling D
On Sunday, 26 January 2014 at 14:17:18 UTC, Russel Winder wrote: On Sun, 2014-01-26 at 12:11 +, Russel Winder wrote: […] However with Python 2 the example from: https://bitbucket.org/ariovistus/pyd/wiki/QuickStart leads to: This all sounds suspiciously like stuff I thought I'd already fixed. see https://bitbucket.org/ariovistus/pyd/issue/15/some-issues-getting-pyd-to-work
Re: Python calling D
On Saturday, 1 February 2014 at 22:02:24 UTC, Russel Winder wrote: My problem of the moment is segmentation faults during execution, and I have no model of how to go about providing useful data to debug this :-(( It wouldn't by any chance be related to https://bitbucket.org/ariovistus/pyd/issue/17/it-seems-py_incref-missed-when-pydobject would it?
Re: GDC and Fedora 20
On Wednesday, 15 January 2014 at 18:34:41 UTC, Dejan Lekic wrote: Russel Winder wrote: 2) As Iain noted, I have made GCC SPEC which basically builds what I call system GCC - a set of GCC packages that are installed in /usr . This package is for those brave enough to replace GCC RPMs with my GCC RPMs. I use this for years, however I did not have time to work on 4.8 RPMs. It should not take long for me to provide SPEC for 4.8.x, but what will take long is to provide support for various Fedora versions (check pkgs.fedoraproject.org , search for gcc). I do not have time for this, as I have more important projects I work on, that is why I never announced availability of Fedora GCC SPEC file which builds GDC as well. When I made my gdc rpms I had it build the entire gcc and then just pull out the ~ 10 new files and install those on top of gcc
Re: Python calling D
On Friday, 24 January 2014 at 10:55:34 UTC, Russel Winder wrote: Probably want to use a virtualenv for this rather than install into the base installation you can also do python setup.py build python runtests.py -b hello It needs to work for Python 3.3 as well! try the latest commit
Re: Shared library: loading doesn't call shared static this
On Sunday, 8 December 2013 at 10:31:32 UTC, Mathias LANG wrote: Thank you, and yazd, it did the trick. May I ask why I don't want to call it multiple time though ? From the sentence If the runtime was already successfully initialized this returns true., I though this was handled in some way. Or do you mean, multiple time in case of multiple libraries ? rt_term at least will [did] segfault when you call it a second time. So just don't have N shared libs each with a ctor calling rt_init and dtor calling rt_term.
Re: how to compose delegate type
On Sunday, 8 December 2013 at 00:43:51 UTC, Jesse Phillips wrote: What is wrong with the current template which returns an immutable delegate type? It still store you're immutable member function. It composes the wrong type. It composes a type that has different constness than the target type, which will likely cause problems due to transitive const. Anyways, I'm trying to find a workaround to https://d.puremagic.com/issues/show_bug.cgi?id=11694
Re: Shared library: loading doesn't call shared static this
On Saturday, 7 December 2013 at 20:11:15 UTC, Mathias LANG wrote: afaik, druntime does not officially support the C main, D shared library use case yet. If you have only 1 D shared library, you can insert calls to rt_init and rt_term into shared lib constructors/dtors with gcc. This has worked for me in pyd: https://bitbucket.org/ariovistus/pyd/src/32cf9709d711/examples/misc/dmd_sharedlibs/?at=default You don't want to be calling rt_init or rt_term multiple times, though.
Re: how to compose delegate type
On Saturday, 7 December 2013 at 19:36:50 UTC, Jesse Phillips wrote: This declaration doesn't make sense to me: string a() immutable { return 1; } http://dlang.org/class.html#member-functions
Re: how to compose delegate type
On 12/05/2013 09:33 PM, Jesse Phillips wrote: I don't think I understand what you mean: this code illustrates it: class Z { string a() immutable { return 1; } string b() { return 2; } } template F(t) { alias immutable(t) F; } alias typeof(Z.init.a) Texpected; alias typeof(Z.init.a) T; static assert(is(F!(T) == Texpected)); void main() {} above F doesn't work; immutable(void delegate()) and void delegate() immutable are different types (I think the latter means 'this' is immutable). If t were a function pointer, you would apply the immutable to the pointer target like so: alias immutable(pointerTarget!t)* F
how to compose delegate type
how do I construct F!(T) to yield void delegate() immutable when T is void delegate() ? [its been a long day]
Re: PyD status on fedora 19?
On Wednesday, 27 November 2013 at 16:37:36 UTC, Neal Becker wrote: Just trying PyD on fedora 19 x86_64. I install ldc (and friends) using yum. Then I did hg clone https://bitbucket.org/ariovistus/pyd Now after python setup.py install --user, I go to try hello: [nbecker@nbecker7 hello]$ python tsetup.py build --compiler=ldc use dmd. ldc doesn't support building shared libraries.
Re: PyD status on fedora 19?
On Saturday, 30 November 2013 at 05:51:43 UTC, Ellery Newcomer wrote: use dmd. ldc doesn't support building shared libraries. also, use 2.063. I think compilation broke in 2.064 for some reason. I plan on fixing this next week.
Re: Need help making minimal bare metal ARM Cortex-M D program
On 11/24/2013 06:21 AM, Johannes Pfau wrote: Am Sun, 24 Nov 2013 14:19:43 +0100 schrieb Mike n...@none.com: On Sunday, 24 November 2013 at 12:53:42 UTC, Iain Buclaw wrote: On Sunday, 24 November 2013 at 12:43:01 UTC, Mike wrote: I am very new to D, but I finally got my toolchain compiled and working. I'm using LDC. I failed with GDC and eventually gave up. I know Johannes has some patches yet to trickle down into gdc. And druntime is does not support ARM fully in 2.063, but it would be helpful if you could take some time to let people know what went wrong when you tried things, rather than just giving up. Otherwise, nothing will get fixed. Cortex-M is the 'bare metal' branch of ARM where you usually don't run linux so druntime won't work anyway. There are some compiler fixes in my branch that could be interesting though: https://github.com/jpf91/GDC/commits/arm BTW: I'll start merging back the fixes to gdc master this week. Some fixes have to be merged into phobos upstream though so it might take some time. I actually tried to get a gdc build a week or two ago for a cortex-a8 using ng-crosstools-linaro. I managed to get up to compiling druntime, which then was pointing to a commit prior to https://github.com/D-Programming-Language/druntime/commit/541e7ba00d5e75426bb677d7f7548a47a904551f so it failed. Then I figured I'd wait for your fixes.
core.sys.posix.termios
is there any particular reason it is missing B115200 and friends?
Re: Red-Black tree storing color without additional memory requirements
On 11/20/2013 06:50 AM, bearophile wrote: safety0ff: Since the GC supports interior pointers, I think you can justify using the least significant bits as long as the size and alignment of the pointed object guarantee that the pointer + tag will always lie inside the memory block. From: http://dlang.org/garbage.html Do not take advantage of alignment of pointers to store bit flags in the low order bits: Bye, bearophile ha. I did this with steve's rb tree. hasn't bit me yet.
Re: bitwise operation and type
On 11/20/2013 11:21 PM, bioinfornatics wrote: why this fail http://www.dpaste.dzfl.pl/a6d6acf4 as with c, most of the integer operators return int for integral types smaller than int. also, this is a case where a += b does something different than a = a + b i guess the former automatically inserts a cast or something. I want to works with ubyte - i do not want use int for manipulating these byte and consume more memory as need! tough. use a cast.
Re: Fedora RPMs
On 11/19/2013 12:14 AM, Dejan Lekic wrote: by gum, I think you did it right too. I can build a shared lib straight out of the box. Well, unittests seem not to be running, and I'm sure they were a release or two ago. we'll see. I did not check unittests to be honest, will do that later. Well, don't worry too much; I'm doing Unsupported Things: https://bitbucket.org/ariovistus/pyd/src/32cf9709d711bd447941be4e11e09727d8747b7c/examples/misc/dmd_sharedlibs/?at=default But I checked, the unittest definitely ran in dmd 2.063.2 with my build at least. I also noticed some odd compilation failures so had to revert to above build. When I get done with my custodial work on pyd (which might take a while), I'll switch back to your rpms and poke around more.
Re: DIP 50 - AST macros
On 11/18/2013 11:21 AM, Kapps wrote: On Monday, 18 November 2013 at 16:03:54 UTC, IgorStepanov wrote: it can't be used to generate new code. Sure it can. Generate lambda expression tree; invoke Compile(). You just can't rewrite existing code.
Re: Fedora RPMs
On 11/18/2013 05:11 PM, Dejan Lekic wrote: Hello everybody. I have just committed few changes to https://www.gitorious.org/dejan- fedora that allow you to build functional RPMs on your Fedora 19 systems. I will aim for now to support F19, F20, EL5 and EL6. If someone needs support for something else, please send patches or just simply come to IRC and let me know what is the problem. :) this is pretty nice setup you got here. Few remarks - SPEC file expects source files to be on http://ddn.so/ files/ . I hope our release manager, or so-called build master will make sure dlang.org provides source tarballs of dmd, phobos, druntime and tools the same or similar way I have them on http://ddn.so/files/ (btw, you can't browse it yet, but you can download files). would it be possible to link to appropriate github repo changesets using git submodule, and then generate the tarballs from those? I use the simple get-files.sh (located in the dmd directory in the dejan- fedora repo) to get those release tarballs from GitHub. Finally, I decided to be little bit adventurous and made the SPEC file generate dmd.conf with -defaultlib=libphobos2.so flag in DFLAGS. by gum, I think you did it right too. I can build a shared lib straight out of the box. Well, unittests seem not to be running, and I'm sure they were a release or two ago. we'll see. Following Fedora package guidelines, I provide static library in the libphobos-static package instead. lovely. wait, 42 megabytes? there's one file in that package.. wow. So far it all works fine. I did not test the i686 packages yet, they should work. :) Kind regards, and I hope you find this useful as much as I do. Me too, I'm sick of maintaining my own buildscripts. A few suggestions: /usr/share/d/samples is in dmd-...-{architecture???}, shouldn't they be in a noarch package, like libphobos-devel? shouldn't dmd require libphobos-devel rather than libphobos? libphobos installs libphobos.so.2.064; shouldn't it have also installed libphobos2.so.2.064.2, cuz you know, this is dmd 2.064.2, and also most libs in my /usr/lib seem to follow the format libname.so.x.y.z no dustmite? waaa.. ok fine. From my own experience, I believe you are going to want Requires: glibc-devel(x86-32) Requires: glibc-devel(x86-64) in the dmd package to ensure -m32/-m64 work properly feel free to take any more from https://bitbucket.org/ariovistus/rpm-buildscripts/src/21921c736116a51f60db4ab9cb5852fc0ae0b63c/dmd-git2rpm I don't know if those Provides are necessary, but I do remember it took me a frustrating amount of time to get the 64 bit one right.
Re: (Linux) Which compilers should be working now with shared libraries?
On 11/16/2013 02:40 PM, qznc wrote: On Saturday, 16 November 2013 at 13:00:54 UTC, Martin Nowak wrote: On Friday, 15 November 2013 at 20:17:38 UTC, Marco Leise wrote: Oops, this was answered with not ready yet a few topics earlier. Ok, then static D libs only for now. That applies only to loading, linking shared libraries works. I think telling anybody shared libraries do (not) work is too simplistic. Is there an overview, what does and what does not work with shared libraries? I envision a matrix with one axis dmd, gdc, ldc and one axis linking shared C library, loading/unloading shared C libraries, link shared D library into D, link shared D library into C, ... and then another axis for dmdfe/druntime release, and then another axis for platform, and then another axis for architecture and then this becomes maybe a bit much for a wiki system to handle. But I would like something like this too.
Re: DIP 50 - AST macros
On 11/17/2013 11:41 AM, Simen Kjærås wrote: Source is attached. I hope God forgives me. I suppose you'd have to do something like x.Where(OR( NOT(Args.thing = thing), Args.sing = sing)) for nesting and negation and all that. I'd wait for walter to relax the restrictions on ==, , etc operator overloading. Then you probably could do x.Where(X = X.thing != thing || X.sing == sing) let's see here. If X's type is QueryExp!Entity and the return type is SomeRange!Entity then querying looks doable. how about composing expressions? take the result of that lambda EXP, EXP = EXP X.cling == 1; // should work fine? how about decomposing expressions? EXP = EXP.lhs; // should work fine? EXP.rhs.rhs.value // returns sing - should work fine? the lambda should create a closure, so we should be able to get out any value we put in you won't be able to do x.Where(X = upper(X.thing) == THING) without ast macros but will have to be satisfied with x.Where(X = X.thing.upper() == THING) will you be able to do x.Where(X = X.thing == THING x.Any(X2 = X2.thing == X.thing X2.id != X.id)) ? either Any would have to be only for template expressions, or X would have to be an outer context like so: x.Where(X = X.it.thing == THING X.x.Any(X2 = X2.it.thing == X.it.thing X2.it.id != X.it.id)) because x.Any(...) should return bool, but inside the query expression it should return QueryExp. In both cases it would take a param of QueryExp delegate(QueryExp) Anybody else have any other ideas?
Re: DIP 50 - AST macros
On Wednesday, 13 November 2013 at 10:51:48 UTC, Simen Kjærås wrote: On 12.11.2013 18:53, Ellery Newcomer wrote: It's perfectly possible in D to make this work: hey, cool impl *comprehends code* I mean Ewww I *can* make that work. I'm not going to. -- Simen I concur with the second part.
Re: DIP 50 - AST macros
On 11/12/2013 06:38 AM, John Colvin wrote: On Tuesday, 12 November 2013 at 13:50:49 UTC, Jacob Carlborg wrote: auto person = Person.where(e = e.name == John); Translates to: select * from person where name = 'John' for those of us entirely unfamiliar with linq, what is this supposed to do? Select people with name John from a collection of people, like in sql? It seems trivial to do this using filter, or am I missing something...? linq provides an interface to query any collection, but what is interesting in this case is Person.where(e = e.name == John) invokes an engine that builds the necessary sql to issue an equivalent query to your sql database and assembles the results into a range of Person. And it can do this for any arbitrary predicate (well, almost. It doesn't handle function calls to arbitrary code too well). the .NET framework can do this because it exposes an api for querying, building, and compiling asts. D cannot do this because it doesn't. (and I have tried to make it work)
Re: DIP 50 - AST macros
On Tuesday, 12 November 2013 at 16:14:57 UTC, John Colvin wrote: On Tuesday, 12 November 2013 at 15:21:16 UTC, Ellery Newcomer wrote: On 11/12/2013 06:38 AM, John Colvin wrote: On Tuesday, 12 November 2013 at 13:50:49 UTC, Jacob Carlborg wrote: auto person = Person.where(e = e.name == John); Translates to: select * from person where name = 'John' for those of us entirely unfamiliar with linq, what is this supposed to do? Select people with name John from a collection of people, like in sql? It seems trivial to do this using filter, or am I missing something...? linq provides an interface to query any collection, but what is interesting in this case is Person.where(e = e.name == John) invokes an engine that builds the necessary sql to issue an equivalent query to your sql database and assembles the results into a range of Person. And it can do this for any arbitrary predicate (well, almost. It doesn't handle function calls to arbitrary code too well). the .NET framework can do this because it exposes an api for querying, building, and compiling asts. D cannot do this because it doesn't. (and I have tried to make it work) oh, I see. Would AST macros really be enough to make this work in D? Arbitrary code is a huge feature space in D, including much that doesn't map well to anything outside of a relatively low-level language, let alone SQL. I can see it quickly becoming a nightmare that would be worse than just issuing the predicate as an sql string or some generic equivalent. Actually, s/arbitrary code/simple to moderately complex expressions that don't call functions that aren't explicitly handled by the translation engine/ and this is a better representation of what linq can do in e.g. entity framework. and you could go the route of django models, e.g. Place.objects.filter(name=Bob's Cafe) as long as you had enough metadata set up. you could probably get this to work in D, but A. it looks like crap B. it in no way resembles sql C. it would look like even worse crap in D (no named parameters!) D. it doesn't readily permit you to make queries with complex expression trees (idk, maybe something like linq's Places.Where(p = p.Elev 200 Addresses.Any(a = a.State == p.State)) why am I arguing against this? nobody wants this, nobody asked for this. Also, sql is to databases what assembly is to cpus. It's low level, [moderately] untyped, and it differs on every single platform. provide access to it, sure, but please don't use it to build your abstractions.
Re: bidirectional map
On 11/11/2013 05:14 PM, bioinfornatics wrote: Dear, I am looking for a bidirectional map i.e http://en.wikipedia.org/wiki/Bidirectional_map My seach into D documentation seem to said to me that this structure is not implemented. Something like (for primary idea): struct BidirectionalMap(T,U){ private: T[U] _forwardHash; U[T] _reverseHash; public: @safe void opIndeyAssign( T k, U v){ // pure? _forwardHash[k] = v; _reverseHash[v] = k; } @property BidirectionalMap!(T,U) dup(){ return BidirectionalMap!(T,U)( this ); } } you could build one using multi_index. https://bitbucket.org/ariovistus/multi_index at least, that is how boost::bimap was done. I always assumed it would be trivial in D, but I haven't tried doing it. Something like alias MultiIndexContainer!(Tuple!(T,t,U,u), IndexedBy!(HashedUnique!(a.t), HashedUnique!(a.u))) BiMap; and then wrap as you see fit.
Re: DIP 50 - AST macros
On 11/10/2013 01:20 PM, Jacob Carlborg wrote: I've been thinking quite long of how AST macros could look like in D. I've been posting my vision of AST macros here in the newsgroup a couple of times already. I've now been asked to create a DIP out of it, so here it is: http://wiki.dlang.org/DIP50 For macros that generate macros, I think you need a way to escape the splicing and maybe define how splicing works in an inner quasi quote. I guess you want [ [ $exp ] ] to turn into the ast [ 1 ] Then if you wanted ast [ [ $exp ] ] with the splice associated with the inner quasi quote, you'd have to do something like [ [ [ \\\$exp ] ] ] maybe a way to associate a splice with a quasi quote? a[ b[ c[ $(a, exp) + $(b, exp) + $(c, exp) ] ] ] a's exp is A b's exp is B c's exp is C then splice the quasi quote N times: 1: ast b[ c[ A + $(b, exp) + $(c, exp) ] ] 2: ast c[ A + B + $(c, exp) ] 3: ast A + B + C just dinking around here
Re: DIP 50 - AST macros
On 11/11/2013 12:06 PM, deadalnix wrote: On Monday, 11 November 2013 at 19:23:21 UTC, Ellery Newcomer wrote: On 11/10/2013 01:20 PM, Jacob Carlborg wrote: I've been thinking quite long of how AST macros could look like in D. I've been posting my vision of AST macros here in the newsgroup a couple of times already. I've now been asked to create a DIP out of it, so here it is: http://wiki.dlang.org/DIP50 For macros that generate macros, I think you need a way to escape the splicing and maybe define how splicing works in an inner quasi quote. I guess you want [ [ $exp ] ] to turn into the ast [ 1 ] Then if you wanted ast [ [ $exp ] ] with the splice associated with the inner quasi quote, you'd have to do something like [ [ [ \\\$exp ] ] ] maybe a way to associate a splice with a quasi quote? a[ b[ c[ $(a, exp) + $(b, exp) + $(c, exp) ] ] ] a's exp is A b's exp is B c's exp is C then splice the quasi quote N times: 1: ast b[ c[ A + $(b, exp) + $(c, exp) ] ] 2: ast c[ A + B + $(c, exp) ] 3: ast A + B + C just dinking around here $ refers to the enclosing scope. so $$foo should refers to $foo in the enclosing scope. No need for special rule or label. so if I have to splice my ast N times, then I have to generate M $'s depending on when I want it to expand?
Re: spurious gc allocation
On 11/09/2013 12:35 AM, lomereiter wrote: Indeed, disassembly reveals an allocation (with all three compilers = it's the front-end which generates this crap). ouch. I guess the compiler incorrectly treats { node.value; } as a delegate and copies the node to GC heap. void foo() { int* node = null; enum mutable = __traits(compiles, {node.value ;}); } void main() { foo(); } oh, I see, it's the delegate doing that. that's helpful. https://d.puremagic.com/issues/show_bug.cgi?id=11483
Re: spurious gc allocation
On 11/08/2013 06:19 AM, Timon Gehr wrote: On 11/08/2013 07:12 AM, Benjamin Thaut wrote: The problem is that you define the struct Thing as a inner struct. struct Thing only exists in the decompiled version, not in the original source. So far it looks like a bug to me. I've reduced it to the following: a.d: class C { void _InsertAllBut(int v) { int* node = null; enum mutable = __traits(compiles, {node.value ;}); } } test.d: import a; void main () { C c = new C(); c._InsertAllBut(1); } compile: dmd test.d a.d order doesn't seem to matter, works with -m32 and -m64, apparently I am running dmd v2.063-devel-e23c785 objdump -d --disassembler-options=intel test | ddemangle shows me ... 00417888 void a.C._InsertAllBut(int): 417888: 55 push rbp 417889: 48 8b ecmovrbp,rsp 41788c: 48 83 ec 38 subrsp,0x38 417890: 53 push rbx 417891: 48 89 7d f0 movQWORD PTR [rbp-0x10],rdi 417895: 48 bf 10 00 00 00 00movabs rdi,0x10 41789c: 00 00 00 41789f: e8 10 22 00 00 call 419ab4 _d_allocmemory 4178a4: 48 89 45 e0 movQWORD PTR [rbp-0x20],rax 4178a8: 48 8b 4d f0 movrcx,QWORD PTR [rbp-0x10] 4178ac: 48 89 08movQWORD PTR [rax],rcx 4178af: 48 85 c9test rcx,rcx ... can anyone confirm?
spurious gc allocation
hello all. I have a class member function that essentially looks like this: ThisNode* _InsertAllBut(int value) { ThisNode* node = MallocAllocator.allocate!(ThisNode)(1); node.value = value; node_count++; return node; } I compile it on x86_64 and the compiler inserts a gc allocation. I decompiled it, and it looks like it does this: ThisNode* _InsertAllBut(int value) { struct Thing { typeof(this) thing1; ThisNode* thing2; int thing3; } Thing* rbp28 = _d_allocmemory(0x14); rbp28.thing1 = this; rbp28.thing3 = value; if (this == 0) { // not wasting my time figuring out _d_assert_msg's calling conventions r8d = 0x137c; rcx = something pointing to src/multi_index.d; rdi = {length associated with rsi}; rsi = something pointing to null this; rdx = {length associated with rcx}; _d_assert_msg(); } invariant._d_invariant(this); rbp28.thing2 = MallocAllocator.allocate(1); rbp28.thing2.value = rbp28.thing3; this.nodecount ++; return rbp28.thing2; } So. Why the heck is it using heap space for stack space? How the heck am I supposed to call this from within a destructor?
Re: GCD and Fedora
On 09/29/2013 01:46 AM, Russel Winder wrote: Is anyone else interested in getting D technologies into Fedora 19 I am
Re: PyD status and tutorials
On Saturday, 31 August 2013 at 15:44:03 UTC, Russel Winder wrote: On Sat, 2013-08-31 at 12:56 +0200, Larry wrote: Ok python3-dev was missing. Are you using Python 3.3? Are you using SCons or Tup for the build? I just tried the SCons build OOTB and it fails to build PyD with DMD :-( Ehh, yeah. I gave up on build systems a while back because it made it unnecessarily complicated to set up test vms for more exotic systems. Now we use python setup.py [build|install] because python's always there. OP has that right. Since I've been out of the loop for a while, can gdc build shared libraries yet? That's what OP's build command is trying to do.
Re: DLLs: Cleaning up
On 07/17/2013 08:13 AM, Chris wrote: with some nasty surprises as regards obtaining (valid) paths on Windows as opposed to Linux / Mac. Do tell. (Any time and life saving advice about linking to other libraries / DLLs?) Thanks everyone! celerid should be up to the task.
Re: DLLs: Cleaning up
On 07/15/2013 07:18 AM, Chris wrote: doesn't work with newer versions of dmd does too. (I'm the maintainer) https://bitbucket.org/ariovistus/pyd
getter/setter in one function (almost)
unfortunately, dmd doesn't accept the signature as a valid property. import std.stdio; import std.typecons; struct T { int _i; @property int i(Nullable!int derp = Nullable!int.init) { return _i = derp.isNull ? _i : derp.get; } } void main () { T t; t.i = 1; writeln(t.i); }
Re: DLLs: Cleaning up
On 07/11/2013 05:58 AM, Chris wrote: I have a DLL written in D I load into a Python application via ctypes like so: lib = CDLL(mydll) The DLL loads and can be used no problem. However, once the DLL is discarded of by the program, the program either doesn't react or crashes. I still haven't worked out how to clean up the DLL correctly before it is unloaded / detached (from Python). I guess it's the GC and/or some C stuff I've overlooked. I have tried both approaches described on this page: http://dlang.org/dll.html. Maybe someone of yous once had a similar problem and found a solution. Any hints or suggestions would be appreciated. Thanks. hmm. pyd uses the example under 'DLLs with a C Interface' for its windows dll code and it seems pretty stable, but then it doesn't use ctypes. It doesn't look like you need to be mucking with rt_init and rt_term, so maybe the garbage collector is trying to collect something that python still has a reference to? Also, if you can finagle a dll out of gdc I would love to hear about it. I have not used it on windows, though.
Re: How can i increase max number recursive template expansions?
On 07/07/2013 01:22 PM, John Colvin wrote: On Sunday, 7 July 2013 at 19:55:26 UTC, QAston wrote: I have a large enum in my code (opcodes for a protocol) - using std.traits.EnumMembers gives me a recursive template error. How can i increase max number recursive template expansions? I don't think you can. Please file a bug report: even though it might not get fixed any time soon (other than maybe just upping the threshold), there is talk of enabling more imperative-style programming in templates at the moment, and this would be a good case for it. or feel free to commandeer this one http://d.puremagic.com/issues/show_bug.cgi?id=6471
Re: [Question] Could a function return a list of arguments to call another function?
On 06/28/2013 11:07 AM, MattCoder wrote: Hi, I would like to know if it's possible to pass the return of a function as argument to another function as below: import std.stdio; auto foo(int x, int y){ writeln(x, y); return 3, 4; } void main(){ foo(foo(1,2)); } I would like to print: 1 2 3 4 PS: I tried return a tuple but it doesn't works. Thanks, Matheus. No, functions cannot return tuples. However, they can return std.typecons.Tuple, so you could do this: auto foo(int i, int j) { writeln(i, , j); return tuple(3,4); } void main() { foo(foo(1,2).field); }
Re: how to reflect on function attributes
On 06/05/2013 12:02 AM, Jonathan M Davis wrote: On Wednesday, June 05, 2013 08:52:35 lomereiter wrote: This doesn't work when the method is marked as @property. Any idea why is that so? On Wednesday, 5 June 2013 at 02:19:38 UTC, Jonathan M Davis wrote: is(typeof(A.func) == const) - Jonathan M Davis I don't know. My first guess would be that it thought that it was calling it except that it's being referenced by the type, not by an instance, so that doesn't really make sense. - Jonathan M Davis P.S. Please don't top-post. It makes it harder to follow posts and is generally considered bad newsgroup etiquette. pragma(msg, is(FunctionTypeOf!(A.func) == const));
how to reflect on function attributes
specifically, const, eg. class A { void func() const { blah } } std.traits.FunctionAttributes makes no mention of it
Re: how to reflect on function attributes
On 06/04/2013 07:19 PM, Jonathan M Davis wrote: On Tuesday, June 04, 2013 19:03:47 Ellery Newcomer wrote: specifically, const, eg. class A { void func() const { blah } } std.traits.FunctionAttributes makes no mention of it is(typeof(A.func) == const) - Jonathan M Davis I think that is for type only. It returns false for me.
Re: how to reflect on function attributes
On 06/04/2013 07:43 PM, Jonathan M Davis wrote: On Tuesday, June 04, 2013 19:23:45 Ellery Newcomer wrote: On 06/04/2013 07:19 PM, Jonathan M Davis wrote: On Tuesday, June 04, 2013 19:03:47 Ellery Newcomer wrote: specifically, const, eg. class A { void func() const { blah } } std.traits.FunctionAttributes makes no mention of it is(typeof(A.func) == const) - Jonathan M Davis I think that is for type only. It returns false for me. What do you mean for type only? const is part of the type. What else would it be part of? For the code example that you gave (minus the blah in the middle), it returns true. - Jonathan M Davis Ah, you're right. don't know how I screwed that up.
Re: how to reflect on function attributes
Ah, you're right. don't know how I screwed that up. Yes I do. I was trying to use typeof(A.func)
Re: dmd 2.063 released with 260 bugfixes and enhancements
On 06/02/2013 11:48 AM, Russel Winder wrote: On Sun, 2013-06-02 at 11:23 -0700, Ellery Newcomer wrote: […] who packages your dmd? Normally I would use the one from APT-D, but as this not at 2.063 as yet I used the deb downloaded from the D download page. This necessitates removing all packages from APT-D since they depend on exactly a given DMD version. I have this installed GtkD from master/HEAD and not got Vibe.d just at the minute. so we are using the same package. ?? oh. dpkg -L just doesn't list it. but it's definitely missing from the rpm.
Re: dmd 2.063 released with 260 bugfixes and enhancements
On 06/02/2013 12:56 PM, Russel Winder wrote: On Sun, 2013-06-02 at 12:48 -0700, Ellery Newcomer wrote: […] so we are using the same package. ?? oh. dpkg -L just doesn't list it. Symbolic links aren't in the deb, they are created by the post install script once the shared library is installed. but it's definitely missing from the rpm. Perhaps RPMs should have a post install script? you can package relative links in rpm. https://bitbucket.org/ariovistus/rpm-buildscripts/src/21921c736116a51f60db4ab9cb5852fc0ae0b63c/dmd-git2rpm?at=default#cl-293
Re: Error after installing DMD v2.063
On 06/02/2013 06:47 AM, Gary Willoughby wrote: I've just run: sudo ln -s /usr/lib/x86_64-linux-gnu/libphobos2.so /usr/lib/x86_64-linux-gnu/libphobos2.so.0.63 for now but i've never had to do that before. Is this a problem with the installer? same problem with rpm installer. http://d.puremagic.com/issues/show_bug.cgi?id=10245
Re: Error after installing DMD v2.063
On 06/02/2013 02:00 PM, Russel Winder wrote: is non-standard and not compliant. The standard structure should be: libphobos2.so.0.63 the file libphobos2.so.0 a symbolic link to libphobos2.so.0.63 libphobos2.so a symbolic link to libphobos2.so.0 what is libphobos2.0 ?
Re: Error after installing DMD v2.063
On 06/02/2013 02:20 PM, Jonathan M Davis wrote: he was talking about making it up to the maintainers to create the various symlinks, which IMHO is unacceptable long term why?
Re: Error after installing DMD v2.063
On 06/02/2013 02:51 PM, Russel Winder wrote: On Sun, 2013-06-02 at 14:13 -0700, Ellery Newcomer wrote: On 06/02/2013 02:00 PM, Russel Winder wrote: is non-standard and not compliant. The standard structure should be: libphobos2.so.0.63 the file libphobos2.so.0 a symbolic link to libphobos2.so.0.63 libphobos2.so a symbolic link to libphobos2.so.0 what is libphobos2.0 It is the soname concept. A soname specifies the number of API compatible versions. Basically it relates to the major version of an API. cf. for example: http://en.wikipedia.org/wiki/Soname http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html http://www.netfort.gr.jp/~dancer/column/libpkg-guide/libpkg-guide.html#shlibpkgs $ objdump -p libphobos2.so | grep SONAME SONAME libphobos2.so.0.63
Re: Error after installing DMD v2.063
On 06/02/2013 04:12 PM, Russel Winder wrote: On Sun, 2013-06-02 at 16:03 -0700, Ellery Newcomer wrote: […] $ objdump -p libphobos2.so | grep SONAME SONAME libphobos2.so.0.63 Exactly, the actual file should have the fully qualified soname and all other filenames should be symbolic links to that file. Currently the DMD deb reverses this and therefore violates the standard for deb installation. actually, your resource above says that the soname should have the format lib{lib}.so.X and the real name should have the format lib{lib}.so.X.Y.Z where X = version number Y = minor version number Z = release number so the generated .so itself violates the standard.
Re: Error after installing DMD v2.063
On 06/02/2013 03:05 PM, Jonathan M Davis wrote: On Sunday, June 02, 2013 22:52:59 Russel Winder wrote: On Sun, 2013-06-02 at 14:20 -0700, Jonathan M Davis wrote: […] Create a bug report for it. I don't think that Walter realizes what's standard. And this whole problem probably stems from the fact that he can't put symlinks in the zip file that he generates, so he was talking about making it up to the maintainers to create the various symlinks, which IMHO is unacceptable long term, but it seems to require either changing the main release from a zip to something like 7zip or breaking it up per OS like a number of people have been asking for for ages. Regardless, the fact that the installer and rpm and whatnot are broken is unacceptable. Not being able to put symlinks in a zipfile has nothing to do with getting deb files and RPM files correct since they should be built from tarballs. Sounds like the system for creating distributions is broken. It's done entirely by Walter on his own systems, and I suspect that the deb and rpm files are created from the zip file (though I'm not sure if he creates those or someone else does). We need to change it so that the process for generating them is automated and does not rely on Walter. Work is being done in that area, but it does not appear to be a priority for Walter. - Jonathan M Davis I thought the packages were generated using the scripts at https://github.com/D-Programming-Language/installer/tree/master/linux which pull the zip files from ftp.digitalmars.com What would an automated process look like? I would think something like a script which makes a tarball out of the git repos and then some more which turn the tarball into rpm or deb or what have you?
Re: Error after installing DMD v2.063
On 06/02/2013 04:50 PM, Jonathan M Davis wrote: On Sunday, June 02, 2013 16:42:12 Ellery Newcomer wrote: I thought the packages were generated using the scripts at https://github.com/D-Programming-Language/installer/tree/master/linux which pull the zip files from ftp.digitalmars.com They may. I don't know what the current process is with regards to the rpms and debs, but that would mean that they are indeed using the zips, which is why you're having the problems that you're having. What would an automated process look like? I would think something like a script which makes a tarball out of the git repos and then some more which turn the tarball into rpm or deb or what have you? Something like that. The autotester is already doing that sort of thing for building and running the unit tests. It shouldn't be that hard to make it then generate the correct packages as part of that for the cases where we want it, and if done right, the same process could be used on other boxes. - Jonathan M Davis where is this mythical autotester, anyways?
Re: Error after installing DMD v2.063
On 06/02/2013 05:08 PM, Jonathan M Davis wrote: On Sunday, June 02, 2013 16:57:08 Ellery Newcomer wrote: where is this mythical autotester, anyways? Mythical? Oh ye of little faith: http://d.puremagic.com/test-results/ dmd, druntime, and Phobos are built are their unit tests run after every commit. And the pull tester ( http://d.puremagic.com/test-results/pulls.ghtml?projectid=1 ) tests every pull request the same way (if the submitter is on the whitelist anyway). The code for the auto tester can be found here: https://github.com/braddr/d-tester - Jonathan M Davis what distro are those linux tests performed on?
Re: Error after installing DMD v2.063
On 06/02/2013 05:15 PM, Jonathan M Davis wrote: On Sunday, June 02, 2013 17:08:41 Walter Bright wrote: Regardless, the symlink issue alone shows that using the zip file format for *nix is a mistake. Any packages released for *nix needs to support symlinks correctly. - Jonathan M Davis Is it so hard to convert the zip to tarball in the installer scripts? (hint: no)
Re: Error after installing DMD v2.063
On 06/02/2013 05:29 PM, Jonathan M Davis wrote: On Sunday, June 02, 2013 17:20:37 Ellery Newcomer wrote: what distro are those linux tests performed on? I don't know. You'd probably have to ask Brad Roberts. - Jonathan M Davis just asking because the rpm script in installer is set up to only run on debian.
Re: Error after installing DMD v2.063
On 06/02/2013 05:29 PM, Jonathan M Davis wrote: On Sunday, June 02, 2013 17:24:47 Ellery Newcomer wrote: On 06/02/2013 05:15 PM, Jonathan M Davis wrote: On Sunday, June 02, 2013 17:08:41 Walter Bright wrote: Regardless, the symlink issue alone shows that using the zip file format for *nix is a mistake. Any packages released for *nix needs to support symlinks correctly. - Jonathan M Davis Is it so hard to convert the zip to tarball in the installer scripts? (hint: no) But unless the zip itself is fixed, then anyone downloading it is going to end up with a screwed up *nix setup unless they fix it themselves. It would be far better to just fix the zip. - Jonathan M Davis wouldn't they have a screwed up setup with a tarball as well? They'd still need to fix $PATH and whatever you need to fix to make -lphobos2 work.
Re: Error after installing DMD v2.063
On 06/02/2013 05:47 PM, Jonathan M Davis wrote: On Sunday, June 02, 2013 17:43:20 Ellery Newcomer wrote: On 06/02/2013 05:29 PM, Jonathan M Davis wrote: On Sunday, June 02, 2013 17:24:47 Ellery Newcomer wrote: On 06/02/2013 05:15 PM, Jonathan M Davis wrote: On Sunday, June 02, 2013 17:08:41 Walter Bright wrote: Regardless, the symlink issue alone shows that using the zip file format for *nix is a mistake. Any packages released for *nix needs to support symlinks correctly. - Jonathan M Davis Is it so hard to convert the zip to tarball in the installer scripts? (hint: no) But unless the zip itself is fixed, then anyone downloading it is going to end up with a screwed up *nix setup unless they fix it themselves. It would be far better to just fix the zip. - Jonathan M Davis wouldn't they have a screwed up setup with a tarball as well? They'd still need to fix $PATH and whatever you need to fix to make -lphobos2 work. All you should have to do is set the PATH so that it has dmd in it. Everything else should just work. - Jonathan M Davis Okay, so I unzip to /home/ellery/Downloads/dmd2, add ~/Downloads/dmd2/linux/bin64 to PATH, and try to build a shared library. At runtime, it gives me ./test1.x: error while loading shared libraries: libphobos2.so.0.63: cannot open shared object file: No such file or directory And I don't even remember how to fix this. You have to muck around with ldconfig, which requires root, or something. Maybe there is a way to make the compiler point the shared lib dependency to /home/ellery/Downloads/linux/lib64/libphobos2.so ? But yuck.
Re: Error after installing DMD v2.063
On 06/02/2013 03:25 PM, Nick Sabalausky wrote: On Sun, 02 Jun 2013 22:52:59 +0100 Russel Winder rus...@winder.org.uk wrote: Sounds like the system for creating distributions is broken. Yea, I'm working on a replacement. do tell