Re: How would you dive into a big codebase

2014-10-21 Thread safety0ff via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 01:21:19 UTC, Freddy wrote: Is there any advice/tips for reading medium/big D codebases? Somewhat D specific: I would consider an IDE/editor like Eclipse with DDT that can give an outline of the data structures & functions names in a source file to make the fi

Re: How would you dive into a big codebase

2014-10-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 01:21:19 UTC, Freddy wrote: Is there any advice/tips for reading medium/big D codebases? I'm not aware of there being anything about D which makes it any different to dig into a large codebase than it is for any other language. The usual suggestion that I've h

Re: Sorting array of string arrays by an element in the string array

2014-10-21 Thread neal via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 01:58:19 UTC, neal wrote: On Wednesday, 22 October 2014 at 01:02:17 UTC, bearophile wrote: neal: Anybody have any suggestions? Something like this, perhaps? data.sort!q{ a[4] > b[4] }; Bye, bearophile Hmmm.. Im getting some interesting results here. So wh

Re: bitmanip bigEndianToNative using a buffer slice?

2014-10-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 22, 2014 00:45:17 Lucas Burson via Digitalmars-d-learn wrote: I'm trying to create a primitive type given a specific buffer slice. I can place the uint into a sliced buffer but I'm getting compiler errors when using a slice to create the uint. Still new to Dlang and unfamil

Re: Sorting array of string arrays by an element in the string array

2014-10-21 Thread neal via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 01:02:17 UTC, bearophile wrote: neal: Anybody have any suggestions? Something like this, perhaps? data.sort!q{ a[4] > b[4] }; Bye, bearophile Hmmm.. Im getting some interesting results here. So when i put all of the populations in an area and used this cod

Re: bitmanip bigEndianToNative using a buffer slice?

2014-10-21 Thread ketmar via Digitalmars-d-learn
On Wed, 22 Oct 2014 01:30:48 + Lucas Burson via Digitalmars-d-learn wrote: > ketmar, we meet again! Your explanation is great and that solved > my problem. Thank you. Maybe I'll try out templates next... yep, i remember. i was glad to help you. ;-) signature.asc Description: PGP signature

Re: bitmanip bigEndianToNative using a buffer slice?

2014-10-21 Thread Lucas Burson via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 01:08:52 UTC, ketmar via Digitalmars-d-learn wrote: the short answer: uint fromBuf = bigEndianToNative!uint(cast(ubyte[4])buffer[offset..offset+4]); ketmar, we meet again! Your explanation is great and that solved my problem. Thank you. Maybe I'll try out t

How would you dive into a big codebase

2014-10-21 Thread Freddy via Digitalmars-d-learn
Is there any advice/tips for reading medium/big D codebases?

Re: bitmanip bigEndianToNative using a buffer slice?

2014-10-21 Thread ketmar via Digitalmars-d-learn
On Wed, 22 Oct 2014 00:45:17 + Lucas Burson via Digitalmars-d-learn wrote: > I'm trying to create a primitive type given a specific buffer > slice. I can place the uint into a sliced buffer but I'm getting > compiler errors when using a slice to create the uint. Still new > to Dlang and un

Re: Sorting array of string arrays by an element in the string array

2014-10-21 Thread bearophile via Digitalmars-d-learn
neal: Anybody have any suggestions? Something like this, perhaps? data.sort!q{ a[4] > b[4] }; Bye, bearophile

bitmanip bigEndianToNative using a buffer slice?

2014-10-21 Thread Lucas Burson via Digitalmars-d-learn
I'm trying to create a primitive type given a specific buffer slice. I can place the uint into a sliced buffer but I'm getting compiler errors when using a slice to create the uint. Still new to Dlang and unfamiliar with the template system. How do I get this working? import std.bitmanip; int

Re: Sorting array of string arrays by an element in the string array

2014-10-21 Thread Joel via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 00:32:56 UTC, neal wrote: Just curious if this is possible. I have some data on different countries that i have stored in a multidimensional array called data[][]. What I want to do is sort data[][] by population which happens to be stored in data[i][4] where i

Re: Sorting array of string arrays by an element in the string array

2014-10-21 Thread Joel via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 00:36:22 UTC, Joel wrote: On Wednesday, 22 October 2014 at 00:32:56 UTC, neal wrote: Just curious if this is possible. I have some data on different countries that i have stored in a multidimensional array called data[][]. What I want to do is sort data[][] by

Sorting array of string arrays by an element in the string array

2014-10-21 Thread neal via Digitalmars-d-learn
Just curious if this is possible. I have some data on different countries that i have stored in a multidimensional array called data[][]. What I want to do is sort data[][] by population which happens to be stored in data[i][4] where i is the index to iterate from country to country. I would

Re: Beginner ?. Why does D suggest to learn java

2014-10-21 Thread ketmar via Digitalmars-d-learn
On Wed, 22 Oct 2014 00:57:59 +0300 ketmar via Digitalmars-d-learn wrote: > consitions i don't even know what this word means. honestly. signature.asc Description: PGP signature

Re: Issue with WIKI example Win32_DLLs_in_D

2014-10-21 Thread Laeeth Isharc via Digitalmars-d-learn
Funnily enough I was just playing with this last night trying to get Excel to talk to dlang DLL. I borrowed a C example elsewhere on web and used a different .def file. Something like this: LIBRARY dprop DESCRIPTION 'My DLL written in D' EXETYPE NT CODE

Re: Beginner ?. Why does D suggest to learn java

2014-10-21 Thread ketmar via Digitalmars-d-learn
On Tue, 21 Oct 2014 21:48:14 + Kapps via Digitalmars-d-learn wrote: > I like D's templates, it's one of the things that makes me like D > more than C#. But they can definitely get quite complex. C# > limits templates to generic types, like List, and for a > beginner I think that's an easie

Re: Making plugin system with shared libraries. Upcast in shared lib

2014-10-21 Thread MrSmith via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 13:57:23 UTC, Kagamin wrote: On Monday, 20 October 2014 at 15:07:43 UTC, MrSmith wrote: On Monday, 20 October 2014 at 14:05:29 UTC, Kagamin wrote: Do it the COM way: publish IModule2 interface and declare GetInterface method, which will return a prepared pointer,

Re: Beginner ?. Why does D suggest to learn java

2014-10-21 Thread Kapps via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 09:14:08 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 21 Oct 2014 09:01:32 + Kapps via Digitalmars-d-learn wrote: no template magic that's very bad. it's time to stop making people think that templates are inevitably arcane. I like D's templates,

Issue with WIKI example Win32_DLLs_in_D

2014-10-21 Thread Andre via Digitalmars-d-learn
Hi, by copy and paste the example from http://wiki.dlang.org/Win32_DLLs_in_D exactly as described, the following errors is thrown: J:\Projects\Tests\Example>dmd test mydll.lib -g OPTLINK (R) for Win32 Release 8.00.15 test.obj(test) Error 42: Symbol Undefined _D5mydll12__ModuleInfoZ I created

Re: Global const variables

2014-10-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 17:00:49 UTC, Meta wrote: There is no such thing as global scope in D. While that's technically true (and very good for avoiding symbol conflicts), modules at the module level are still typically referred to as global variables.

Re: Global const variables

2014-10-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 15:51:27 UTC, MachineCode wrote: pure functions are also supposed to don't use global variables at all, according to functional programming paradigm The functional programming paradigm is kind of irrelevant to D's pure, which should really be something more like

Re: Global const variables

2014-10-21 Thread Meta via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 16:56:06 UTC, Solomon E wrote: On Tuesday, 21 October 2014 at 15:51:27 UTC, MachineCode wrote: ... ... pure functions are also supposed to don't use global variables at all, according to functional programming paradigm Pure functions are immutables (constants b

Re: Global const variables

2014-10-21 Thread Solomon E via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 15:51:27 UTC, MachineCode wrote: ... ... pure functions are also supposed to don't use global variables at all, according to functional programming paradigm Pure functions are immutables (constants but not "const" in the D or C++ senses) and can use other immut

Re: Global const variables

2014-10-21 Thread ketmar via Digitalmars-d-learn
On Tue, 21 Oct 2014 16:47:04 + Solomon E via Digitalmars-d-learn wrote: > That's unsafe because the implementation might change, and > pointer arithmetic is unsafe in general. sure, ponter casting is implementation-dependend. but .ptr is guaranteed to work as expected. 'a' is just a `struct

Re: Global const variables

2014-10-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 21, 2014 08:02:50 bearophile via Digitalmars-d-learn wrote: Currently this code gets rejected: const int[] a = [1]; void main() pure { auto y = a[0]; } test2.d(3,14): Error: pure function 'D main' cannot access mutable static data 'a' test2.d(3,14): Error: pure functi

Re: Global const variables

2014-10-21 Thread Solomon E via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 14:25:20 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 21 Oct 2014 13:43:29 + Solomon E via Digitalmars-d-learn wrote: `b[0] = 8;` or `b[] = 8;` changes a. Printing the values for &a and &b shows they're different pointers, but (a is b) returns true.

Re: Global const variables

2014-10-21 Thread MachineCode via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 08:02:52 UTC, bearophile wrote: Currently this code gets rejected: const int[] a = [1]; void main() pure { auto y = a[0]; } test2.d(3,14): Error: pure function 'D main' cannot access mutable static data 'a' test2.d(3,14): Error: pure function 'D main' cannot

Re: Global const variables

2014-10-21 Thread ketmar via Digitalmars-d-learn
On Tue, 21 Oct 2014 17:25:09 +0300 ketmar via Digitalmars-d-learn wrote: > On Tue, 21 Oct 2014 13:43:29 + > Solomon E via Digitalmars-d-learn > wrote: > > > `b[0] = 8;` or `b[] = 8;` changes a. Printing the values for &a > > and &b shows they're different pointers, but (a is b) returns >

Re: Global const variables

2014-10-21 Thread ketmar via Digitalmars-d-learn
On Tue, 21 Oct 2014 13:43:29 + Solomon E via Digitalmars-d-learn wrote: > `b[0] = 8;` or `b[] = 8;` changes a. Printing the values for &a > and &b shows they're different pointers, but (a is b) returns > true. So I still have more to learn about how it does that. that's 'cause '&b' taking a

Re: Making plugin system with shared libraries. Upcast in shared lib

2014-10-21 Thread Kagamin via Digitalmars-d-learn
On Monday, 20 October 2014 at 15:07:43 UTC, MrSmith wrote: On Monday, 20 October 2014 at 14:05:29 UTC, Kagamin wrote: Do it the COM way: publish IModule2 interface and declare GetInterface method, which will return a prepared pointer, which you would reinterpret cast to IModule2. Will it work

Re: Global const variables

2014-10-21 Thread Solomon E via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 12:30:30 UTC, anonymous wrote: On Tuesday, 21 October 2014 at 12:08:35 UTC, Solomon E wrote: On Tuesday, 21 October 2014 at 08:48:09 UTC, safety0ff wrote: const int[] a; int[] b; static this() { b = [1]; a = b; } `a` isn't a reference to `b`. `a` is assigne

Why std.variant.Varian.get is mutable

2014-10-21 Thread Jack Applegame via Digitalmars-d-learn
This doesn't compiles http://dpaste.dzfl.pl/bbcc31fbe016

Re: Global const variables

2014-10-21 Thread anonymous via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 12:08:35 UTC, Solomon E wrote: On Tuesday, 21 October 2014 at 08:48:09 UTC, safety0ff wrote: const int[] a; int[] b; static this() { b = [1]; a = b; } `a` isn't a reference to `b`. `a` is assigned by value and has its own storage. `a` is indeed a copy o

Re: Beginner ?. Why does D suggest to learn java

2014-10-21 Thread ketmar via Digitalmars-d-learn
On Tue, 21 Oct 2014 11:51:16 + via Digitalmars-d-learn wrote: > The problem with template-programming in XSLT/C++/D is that if > you want to learn functional programming you are better off using > a good functional language. templates arent about FP only. yet i agree that Scheme is a very g

Re: Global const variables

2014-10-21 Thread Solomon E via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 08:48:09 UTC, safety0ff wrote: On Tuesday, 21 October 2014 at 08:25:07 UTC, bearophile wrote: Minas Mina: Aren't pure functions supposed to return the same result every time? If yes, it is correct to not accept it. But how can main() not be pure? Or, how can't

Re: Beginner ?. Why does D suggest to learn java

2014-10-21 Thread via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 11:43:56 UTC, ketmar via Digitalmars-d-learn wrote: and other people keep pointing at languages without templates and metaprogramming as "good for learing". it's closed circle. The problem with template-programming in XSLT/C++/D is that if you want to learn funct

Re: Beginner ?. Why does D suggest to learn java

2014-10-21 Thread ketmar via Digitalmars-d-learn
On Tue, 21 Oct 2014 11:20:42 + Paulo Pinto via Digitalmars-d-learn wrote: > People think templates are magic, due to their skillset. and other people keep pointing at languages without templates and metaprogramming as "good for learing". it's closed circle. signature.asc Description: PGP si

Re: Beginner ?. Why does D suggest to learn java

2014-10-21 Thread Paulo Pinto via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 09:14:08 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 21 Oct 2014 09:01:32 + Kapps via Digitalmars-d-learn wrote: no template magic that's very bad. it's time to stop making people think that templates are inevitably arcane. People think template

Re: Global const variables

2014-10-21 Thread bearophile via Digitalmars-d-learn
Szymon Gatner: const int[] a; int[] b; static this() { b = [1]; a = b; } Ant this code works? What is the point of const then if you can assign it to mutable slice? It works, and I think it should work. Inside the (module) constructor the const state is handled differently. Thank

Re: m_condition.mutex cannot be used in shared method ?

2014-10-21 Thread via Digitalmars-d-learn
On Monday, 20 October 2014 at 17:37:22 UTC, Sean Kelly wrote: With all the recent work on the GC, we really really need to start tracking which thread owns a given non-shared object so it can be finalized properly. This may mean having the process of casting away shared make the executing thread

Re: Global const variables

2014-10-21 Thread Szymon Gatner via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 08:48:09 UTC, safety0ff wrote: On Tuesday, 21 October 2014 at 08:25:07 UTC, bearophile wrote: Minas Mina: Aren't pure functions supposed to return the same result every time? If yes, it is correct to not accept it. But how can main() not be pure? Or, how can't

Re: Beginner ?. Why does D suggest to learn java

2014-10-21 Thread ketmar via Digitalmars-d-learn
On Tue, 21 Oct 2014 09:01:32 + Kapps via Digitalmars-d-learn wrote: > no template magic that's very bad. it's time to stop making people think that templates are inevitably arcane. signature.asc Description: PGP signature

Re: Beginner ?. Why does D suggest to learn java

2014-10-21 Thread Kapps via Digitalmars-d-learn
On Thursday, 16 October 2014 at 22:26:51 UTC, RBfromME wrote: I'm a newbie to programming and have been looking into the D lang as a general purposing language to learn, yet the D overview indicates that java would be a better language to learn for your first programming language. Why? Looks l

Re: Global const variables

2014-10-21 Thread safety0ff via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 08:25:07 UTC, bearophile wrote: Minas Mina: Aren't pure functions supposed to return the same result every time? If yes, it is correct to not accept it. But how can main() not be pure? Or, how can't the 'a' array be immutable? Bye, bearophile There can exis

Re: Global const variables

2014-10-21 Thread bearophile via Digitalmars-d-learn
Minas Mina: Aren't pure functions supposed to return the same result every time? If yes, it is correct to not accept it. But how can main() not be pure? Or, how can't the 'a' array be immutable? Bye, bearophile

Re: Global const variables

2014-10-21 Thread Minas Mina via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 08:02:52 UTC, bearophile wrote: Currently this code gets rejected: const int[] a = [1]; void main() pure { auto y = a[0]; } test2.d(3,14): Error: pure function 'D main' cannot access mutable static data 'a' test2.d(3,14): Error: pure function 'D main' cannot

Global const variables

2014-10-21 Thread bearophile via Digitalmars-d-learn
Currently this code gets rejected: const int[] a = [1]; void main() pure { auto y = a[0]; } test2.d(3,14): Error: pure function 'D main' cannot access mutable static data 'a' test2.d(3,14): Error: pure function 'D main' cannot access mutable static data 'a' But is this a good idea? Isn'

Re: Removing whitespace duplicates

2014-10-21 Thread bearophile via Digitalmars-d-learn
Nordlöw: It would be nice to have a lambda-variant of std.string.tr to call like x.tr!isWhite(['_']) If your text is ASCII, then there is std.ascii.whitespace that can be given as argument to std.string.tr. Bye, bearophile

Re: Removing whitespace duplicates

2014-10-21 Thread Nordlöw
On Tuesday, 21 October 2014 at 07:31:59 UTC, Nordlöw wrote: std.string.tr is my preferred choice here :) It would be nice to have a lambda-variant of std.string.tr to call like x.tr!isWhite(['_'])

Re: Removing whitespace duplicates

2014-10-21 Thread Nordlöw
On Monday, 20 October 2014 at 23:25:18 UTC, bearophile wrote: But with tr you can also replace the spaces with the underscore. std.string.tr is my preferred choice here :) Thanks!