Re: dcollections 2.0b

2010-09-07 Thread Steven Schveighoffer

On Mon, 06 Sep 2010 16:52:57 -0400, BLS windev...@hotmail.de wrote:


On 24/08/2010 17:45, Steven Schveighoffer wrote:

dcollections second beta version 2.0b is up.

This fixes a few bugs, and adds some features such as passing in
elements on construction. See the full changelog here:

http://www.dsource.org/projects/dcollections/wiki/ChangeLog

This release is long overdue, sorry to those of you waiting for these
fixes. I've had a very busy summer!

-Steve


Thanks for the update Steve. Once gain, a fantastic collection lib !!

Erm., I hoped for more.. at least for a nitty gritty tutorial - when  
and how to use cursors - ArrayLists/Arrays


Sorry, I've been very busy.  I've had very little time for D, and I was  
way late on releasing this version.  I didn't want to delay it by adding  
extra work.


I'll bump up the tutorial priority...

BTW, I still cannot contact you via your email address, not sure if you  
read my other NG posts about this...


-Steve


Re: Sept. 15 - The Many Faces of D

2010-09-07 Thread Walter Bright

Mike James wrote:
For those of us on different continents - will it be available on 
youtube :-)


I don't know.


Re: Sept. 15 - The Many Faces of D

2010-09-07 Thread Emil Madsen
Would love to see it :)
However for at student in europe, its quite far.
Hoping for availablity of it, on youtube :)

On 7 September 2010 20:16, Walter Bright newshou...@digitalmars.com wrote:

 Mike James wrote:

 For those of us on different continents - will it be available on youtube
 :-)


 I don't know.



-- 
// Yours sincerely
// Emil 'Skeen' Madsen


Re: Sept. 15 - The Many Faces of D

2010-09-07 Thread Phil Deets
On Sun, 05 Sep 2010 03:22:08 -0700, Walter Bright  
newshou...@digitalmars.com wrote:


I'll be giving a presentation on The Many Faces of D at the Northwest  
C++ Users' Group meeting on Sept. 15.


http://nwcpp.org/

3 copies of The D Programming Language book autographed by Andrei will  
be given out as door prizes. Light refreshments, too!


See y'all there.


I'll probably be there. What time does it start?


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread Nick Sabalausky
BCS n...@anon.com wrote in message 
news:a6268ff1b9ca8cd1c2c66c86...@news.digitalmars.com...
 Hello Nick,

 BCS n...@anon.com wrote in message
 news:a6268ff1b9958cd1bfa01297...@news.digitalmars.com...

 Hello Nick,

 Ugh, don't even get me started on MicroSD. Ordinary SD is already
 too small if you ask me, although I still put up with it anyway. Now
 MicroSD, well I can't say anything about it without raising my blood
 pressure...

 My point was that space (volume) is not what limits how much space
 (GB) a phone has.

 And my link dispelled that myth. Try putting 200GB+ into a MicroSD
 form factor at the cost of a 2.5 HDD. Yea, eventually that'll happen,
 but by then I could get a HDD many times bigger than that for the same
 price.


 I wouldn't. I'd put it in a package about 4-5 times as big and mount it on 
 the PC board. Besides, what the heck do you need more than about 32GB for 
 on a phone? If you need to shoot that much video, get a real camera!


Like I said, there's two kinds of phones: phone phones, and PDA 
phones. For the former, I *still* agree with you. For the latter: If I 
were going to blow the money on a smartphone (as they're calling them now) 
or on some sort of iPad-like device (which is the other thing I've been 
talking about), I would expect it to replace a dedicated camera and a 
dedicated portable music player. And they can easily do so just by slapping 
a HDD in there. (BTW, by current music player, which also does video - a 
feature I rather like is 40GB and I find it uncomfortably tight. Plus, with 
that tightness, I can't really use it as an external HDD, which I used to 
do, and found very helpful.) I'm not interested in toting around twenty 
different gadgets. There can be only one!




Re: [Challenge] implementing the ambiguous operator in D

2010-09-07 Thread Peter Alexander
I agree with Andrei here, building hypercubes makes more sense, and feels like 
it has more structure. It
also has the nice property that, once you've seen a (n+1)th element of any 
range then you have already
explored the entire product of the first n elements of every range, kind of 
like how the colex ordering
works.

But which way would you add the successive shells?

Like this?: (00) (01 10 11) (02 12 20 21 22)... i.e. lex order?

btw, what are some real-world uses of the cartesian product of infinite ranges? 
I can't think of any off
the top of my head.


Re: any update on large file support for linux?

2010-09-07 Thread Lars T. Kyllingstad
The SVN version of std.stdio supports large files on Linux and OSX.  The 
next release will be a nice one, I think. :)

-Lars


Thread + socket = (shared) problem? (2.048)

2010-09-07 Thread Bane
This will throw exception on trying to create socket in derived thread. Socket 
created in main thread is ok. Is it some shared issue or... ? I have been 
trying to find something info in docs and mailing list but no result.

import std.stdio;
import core.thread;
import std.socket;

class MyThread : Thread {
  Socket sock;
  this(){
super(run);
  }
  void run(){
writeln(thread start);
sock = new TcpSocket; // this will throw exception on 2.047, 2.048
writeln(thread end);
  }
}

void main(){
  writeln(main start);
  auto s = new TcpSocket;
  writeln(socket in main thread created);
  auto t = new MyThread;
  t.start;
  writeln(main end);
}


Re: Cloning in D

2010-09-07 Thread Jacob Carlborg

On 2010-09-07 04:16, Michel Fortin wrote:

On 2010-09-06 20:55:16 -0400, dsimcha dsim...@yahoo.com said:


== Quote from Michel Fortin (michel.for...@michelf.com)'s article

I'm under the impression that a too permissive generic implementation
of cloning is going to break things in various scenarios.


In general you raise some very good issues, but IMHO the right way to
do cloning
is to have permissive generic cloning that works in the 90% of cases
and can be
easily overridden in the 10% of cases, not to require writing tons of
boilerplate
in the 90% of cases just to make sure it doesn't do the wrong thing by
default in
the 10% of cases.


To me automatic cloning of everything (physical cloning in your
parlance) looks more like 50/50 work/doesn't-work ratio. I can only
guess, but I'm probably used to different use cases than you are.



A second point is that the thing that brought this whole cloning issue
to my mind
was making std.concurrency's message passing model less obtuse. Right
now it's
hard to use for non-trivial things because there's no safe way to pass
complex
state between threads. If we start allowing all kinds of exceptions to
the clone
the **entire** object graph rule, cloning will rapidly become useless
for safely
passing complex object graphs between threads.


This I agree with. I'm not arguing against automatic cloning per-see,
I'm just trying to show cases where it doesn't work well.

Personally, I'm rather skeptical that we can make it safe and efficient
at the same time without better support from the language, something
akin the mythical unique type modifier representing a reference with
no aliasing.



What if your
object or structure is part of a huge hierarchy where things contains
pointers to their parent (and indirectly to the whole hierarchy), will
the whole hierarchy be cloned?


Isn't that kind of the point?


Well, that depends. If you send each leaves of a tree as a message to
various threads presumably to perform something concurrently with the
data in that leaf, then you may want only the leaf to be copied. You may
not want every parent down to the root and then up to every other leaf
to be copied alongside with each message just because the leaf you send
has a pointer to the parent.

In fact, it depends on the situation. If what you want to do with the
leaf in the other thread requires the leaf to know its parent and
everything else, then sure you need to copy the whole hierarchy. But
otherwise it's a horrible waste of memory and CPU to clone the whole
object graph for each message, even though it won't affect the program's
correctness.

And it's basically the same thing with observers. If your observer is a
controller in charge of updating a window when something changes, you
don't want to clone the observer, then clone the window and everything
in it just because you're sending some piece of data to another thread.
Perhaps the program architecture is just wrong, or perhaps that observer
is a synchronized class capable of handling function calls from multiple
threads so it doesn't really need to be copied.



What happens if your object or structure
maintains a reference to a singleton, will we get two instances of a
singleton?


Very good point. I guess the reasonable use case for holding a
reference to a
singleton (instead of just using the globally accessible one) would be
if it's
polymorphic with some other object type? If you're using message passing
concurrency, most of your mutable singletons are probably
thread-local, and what
you probably really want to do is use the thread-local singleton of
the thread
you're passing to.


What intrigues me is how such a mechanism would work... although in my
mind it's probably not even worth supporting at all, singletons be damned!



My understanding is that a data structure containing a pointer cannot
be cloned safely unless it contains some specific code to perform the
cloning. That's because the type system can't tell you which pointers
point to things owned by the struct/class and which one need to be
discarded when cloning (such as a list of observers, or the parents of
a hierarchy).


This discussion is making me think we really need two kinds of
cloning: Physical
cloning would clone the entire object graph no matter what, such that
the cloned
object could be safely passed to another thread via std.concurrency
and be given a
unique type. Logical cloning would be more like what you describe. In
general,
this discussion has been incredibly useful because I had previously only
considered physical cloning.


This is an interesting and valid observation. But I think you need to
leave a door open to customization of the physical cloning case too.
The ability to avoid cloning unnecessary data is as necessary as the
ability to easily copying an entire object graph.


I think everything would be a lot easier if we had support for cloning 
in the standard library. Something like a clone method in Object that as 
a default 

Re: Thread + socket = (shared) problem? (2.048)

2010-09-07 Thread Bane
This is what I get:

std.socket.SocketException: Unable to create socket


Re: Thread + socket = (shared) problem? (2.048)

2010-09-07 Thread Bane
I triple checked it. 2.0.48 has problems with this, 2.040, 2.045  2.047 don't.

 This will throw exception on trying to create socket in derived thread. 
 Socket created in main thread is ok. Is it some shared issue or... ? I have 
 been trying to find something info in docs and mailing list but no result.
 
 import std.stdio;
 import core.thread;
 import std.socket;
 
 class MyThread : Thread {
   Socket sock;
   this(){
 super(run);
   }
   void run(){
 writeln(thread start);
 sock = new TcpSocket; // this will throw exception on 2.047, 2.048
 writeln(thread end);
   }
 }
 
 void main(){
   writeln(main start);
   auto s = new TcpSocket;
   writeln(socket in main thread created);
   auto t = new MyThread;
   t.start;
   writeln(main end);
 }



Re: Thread + socket = (shared) problem? (2.048)

2010-09-07 Thread Bane
Errr... sorry guys.
Joke is on me.

Main threads exits before socket is created in new thread. Simple call to 
sleep() fix this.


Re: Thread + socket = (shared) problem? (2.048)

2010-09-07 Thread Masahiro Nakagawa
On Tue, 07 Sep 2010 18:48:22 +0900, Bane  
branimir.milosavlje...@gmail.com wrote:



Please show your environment. Windows?


WinXP sp2, phenom quad core.


Current std.socket uses static ~this for WSACleanup.
In this case, main thread calls static ~this before MyThread executes  
new TcpSocket.


std.socket workarounds:

1. static ~this - shared static ~this
Main thread calls WSAStartup and WSACleanup.

2. Create reference count
sample code - http://ideone.com/vRMO0

3. other?

I don't know the best way.


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread BCS

Hello Nick,


BCS n...@anon.com wrote in message
news:a6268ff1b9ca8cd1c2c66c86...@news.digitalmars.com...


Hello Nick,


BCS n...@anon.com wrote in message
news:a6268ff1b9958cd1bfa01297...@news.digitalmars.com...

Hello Nick,


Ugh, don't even get me started on MicroSD. Ordinary SD is already
too small if you ask me, although I still put up with it anyway.
Now MicroSD, well I can't say anything about it without raising my
blood pressure...


My point was that space (volume) is not what limits how much space
(GB) a phone has.


And my link dispelled that myth. Try putting 200GB+ into a MicroSD
form factor at the cost of a 2.5 HDD. Yea, eventually that'll
happen, but by then I could get a HDD many times bigger than that
for the same price.


I wouldn't. I'd put it in a package about 4-5 times as big and mount
it on the PC board. Besides, what the heck do you need more than
about 32GB for on a phone? If you need to shoot that much video, get
a real camera!


Like I said, there's two kinds of phones: phone phones, and PDA
phones. For the former, I *still* agree with you. For the latter: If
I were going to blow the money on a smartphone (as they're calling
them now) or on some sort of iPad-like device (which is the other
thing I've been talking about), I would expect it to replace a
dedicated camera and a dedicated portable music player. And they can
easily do so just by slapping a HDD in there. (BTW, by current music
player, which also does video - a feature I rather like is 40GB and I
find it uncomfortably tight. Plus, with that tightness, I can't really
use it as an external HDD, which I used to do, and found very
helpful.) I'm not interested in toting around twenty different
gadgets. There can be only one!



Stuff a person has to store expands to fit the space they have to store it 
in. It's some kind of immutable law of nature that transcends computers and 
closet space. If you had 4.5TB of storage space, then you'd just want to 
store 5TB. The solution isn't more storage space as that just stalls the 
problem for about 10min/Mb.



--
... IXOYE





Re: [Challenge] implementing the ambiguous operator in D

2010-09-07 Thread Andrei Alexandrescu

On 09/07/2010 02:43 AM, Peter Alexander wrote:

I agree with Andrei here, building hypercubes makes more sense, and feels like 
it has more structure. It
also has the nice property that, once you've seen a (n+1)th element of any 
range then you have already
explored the entire product of the first n elements of every range, kind of 
like how the colex ordering
works.

But which way would you add the successive shells?

Like this?: (00) (01 10 11) (02 12 20 21 22)... i.e. lex order?


The algorithm builds one hyperplane at a time. At level k, there are n 
hyperplanes to build, each of which keeps exactly one range positioned 
on the kth element, and all others iterate from their first up to their 
kth element. Whenever you reached the corner of the hypercube (all 
ranges are at the kth position), you start building the next hyperplane. 
When all other hyperplanes are built, you popFront() the first range, 
reset all others, and start building the next shell.



btw, what are some real-world uses of the cartesian product of infinite ranges? 
I can't think of any off
the top of my head.


It's great for various solution-searching algorithms, like the example 
given (lazily generate solutions to the equation x * y = 8). Even for 
finite ranges of moderate size, exploring two iota()s in the naive order 
(keep one fixed and exhaust all others) most often takes a long time to 
find anything interesting. That's why I think finding a solid method to 
iterate the cartesian product is important even for finite ranges.



Andrei


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread retard
Tue, 07 Sep 2010 05:45:55 +, BCS wrote:

 Hello Nick,
 
 BCS n...@anon.com wrote in message
 news:a6268ff1b9958cd1bfa01297...@news.digitalmars.com...
 
 Hello Nick,
 
 Ugh, don't even get me started on MicroSD. Ordinary SD is already too
 small if you ask me, although I still put up with it anyway. Now
 MicroSD, well I can't say anything about it without raising my blood
 pressure...
 
 My point was that space (volume) is not what limits how much space
 (GB) a phone has.
 
 And my link dispelled that myth. Try putting 200GB+ into a MicroSD form
 factor at the cost of a 2.5 HDD. Yea, eventually that'll happen, but
 by then I could get a HDD many times bigger than that for the same
 price.
 
 
 I wouldn't. I'd put it in a package about 4-5 times as big and mount it
 on the PC board. Besides, what the heck do you need more than about 32GB
 for on a phone? If you need to shoot that much video, get a real camera!

I have 32 GB micro-sdhc cards (class 2 or 4) on my phone and 64 GB 
compactflash (don't know the class, but approximately 90 MB/s) on my 
camera (Canon 7D). Both could have more space. The camera doesn't compress 
video very well despite quite high price so the maximum video length is 
only few minutes.

 
 Besides:
 http://www.microcenter.com/search/search_results.phtml?N=4294966955+
 42 94953566sht=Anyprt=NewProduct
 
 If I wanted more sortage than I can put on flash cards, I'd breing a
 lap-top. OTOH: this is the class of phone I use:
 http://www.motorola.com/Consumers/US-EN/Consumer-Product-and-Services
 /Mobile-Phones/Motorola-Stature-i9-US-EN
 
 You're not everyone. Some people would rather have HDD-level storage
 capacity.
 
 
 1) I don't want an HDD in my phone. Moving parts? Ouch! 2) That will
 always be cheaper as an external HDD. Some people will want to use their
 phone as a weapon, should that also be a design criteria?

I'd like to have 128..512 GB of storage in the phone. Why? My media 
library (hundreds of CDs  DVDs transcoded - mp3/ogg or xvid). I think 
this is even possible with two 64 GB sdxc cards. Podcasts. TV series. 
Games. Photos converted to JPG @ 1080p resolution for powerpoint  other 
purposes.

 
 In this day and age, you would be hard pressed to suggest a smart
 phone/PDA needs more than a 1 maybe 2 USB ports. You might, just
 maybe, talk me into believing that an HDMI port could be handy. But
 that would really push it.
 
 Ugh, I hate HDMI, but that's a whole other discussion ;)
 
 
 I just picked the smallest video connector I could think of.

The mini-HDMI is pretty decent. There are no better alternatives that I 
know of at the moment. 1080p video + multichannel audio, quite small.

My phone  cam both also have micro-usb 2.0 connectors. Pretty good. 
Waiting for usb 3.0.


Re: any update on large file support for linux?

2010-09-07 Thread Lars Holowko
On Tue, Sep 7, 2010 at 1:08 AM, Lars T. Kyllingstad
pub...@kyllingen.nospamnet wrote:
 The SVN version of std.stdio supports large files on Linux and OSX.  The
 next release will be a nice one, I think. :)

 -Lars


Thanks Lars,

For the hint to the svn versions. Things seem to work there. What
really surprised me is that dmd compiles

 f.seek(1024 * 1024 * 1024 * 6, SEEK_SET);

but fails with

std.exception.errnoexcept...@std/stdio.d(538): Could not seek in file
`test.txt' (Invalid argument)

whereas

 f.seek(1024 * 1024 * 1024 * 6L, SEEK_SET);

works fine.

I did not realize that 1024 * 1024 * 1024 * 6 turns negative and then
gets converted to a negative long (without even a warning). Overseeing
that had killed my own efforts to hack 64-bit support into phobos ;-)

Thanks again,

(another ;-)) Lars


Re: any update on large file support for linux?

2010-09-07 Thread Andrei Alexandrescu

On 9/7/10 11:05 CDT, Lars Holowko wrote:

On Tue, Sep 7, 2010 at 1:08 AM, Lars T. Kyllingstad
pub...@kyllingen.nospamnet  wrote:

The SVN version of std.stdio supports large files on Linux and OSX.  The
next release will be a nice one, I think. :)

-Lars



Thanks Lars,

For the hint to the svn versions. Things seem to work there. What
really surprised me is that dmd compiles

  f.seek(1024 * 1024 * 1024 * 6, SEEK_SET);

but fails with

std.exception.errnoexcept...@std/stdio.d(538): Could not seek in file
`test.txt' (Invalid argument)

whereas

  f.seek(1024 * 1024 * 1024 * 6L, SEEK_SET);

works fine.

I did not realize that 1024 * 1024 * 1024 * 6 turns negative and then
gets converted to a negative long (without even a warning). Overseeing
that had killed my own efforts to hack 64-bit support into phobos ;-)

Thanks again,

(another ;-)) Lars


Hmmm... the compiler could and should warn about integer overflow in 
computed constant. I suggest you file this as an improvement in bugzilla.


Glad to hear large files are working for you.


Andrei


Re: any update on large file support for linux?

2010-09-07 Thread Lars Holowko
On Tue, Sep 7, 2010 at 9:34 AM, Andrei Alexandrescu
seewebsiteforem...@erdani.org wrote:
 I did not realize that 1024 * 1024 * 1024 * 6 turns negative and then
 gets converted to a negative long (without even a warning). Overseeing
 that had killed my own efforts to hack 64-bit support into phobos ;-)

 Hmmm... the compiler could and should warn about integer overflow in
 computed constant. I suggest you file this as an improvement in bugzilla.

 Glad to hear large files are working for you.


 Andrei


I filed an enhancement request
http://d.puremagic.com/issues/show_bug.cgi?id=4835 as Andrei had
recommended.

Lars


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread domino
BCS Wrote:

 Hello Nick,
 
  BCS n...@anon.com wrote in message
  news:a6268ff1b9ca8cd1c2c66c86...@news.digitalmars.com...
  
  Hello Nick,
  
  BCS n...@anon.com wrote in message
  news:a6268ff1b9958cd1bfa01297...@news.digitalmars.com...
  Hello Nick,
  
  Ugh, don't even get me started on MicroSD. Ordinary SD is already
  too small if you ask me, although I still put up with it anyway.
  Now MicroSD, well I can't say anything about it without raising my
  blood pressure...
  
  My point was that space (volume) is not what limits how much space
  (GB) a phone has.
  
  And my link dispelled that myth. Try putting 200GB+ into a MicroSD
  form factor at the cost of a 2.5 HDD. Yea, eventually that'll
  happen, but by then I could get a HDD many times bigger than that
  for the same price.
  
  I wouldn't. I'd put it in a package about 4-5 times as big and mount
  it on the PC board. Besides, what the heck do you need more than
  about 32GB for on a phone? If you need to shoot that much video, get
  a real camera!
  
  Like I said, there's two kinds of phones: phone phones, and PDA
  phones. For the former, I *still* agree with you. For the latter: If
  I were going to blow the money on a smartphone (as they're calling
  them now) or on some sort of iPad-like device (which is the other
  thing I've been talking about), I would expect it to replace a
  dedicated camera and a dedicated portable music player. And they can
  easily do so just by slapping a HDD in there. (BTW, by current music
  player, which also does video - a feature I rather like is 40GB and I
  find it uncomfortably tight. Plus, with that tightness, I can't really
  use it as an external HDD, which I used to do, and found very
  helpful.) I'm not interested in toting around twenty different
  gadgets. There can be only one!
  
 
 Stuff a person has to store expands to fit the space they have to store it 
 in. It's some kind of immutable law of nature that transcends computers and 
 closet space. If you had 4.5TB of storage space, then you'd just want to 
 store 5TB. The solution isn't more storage space as that just stalls the 
 problem for about 10min/Mb.

That's only true when you're working for Google and steal personal wifi data. 
Ordinary man cannot have 5 TB of data because ALL standard movie/audio 
CD/DVD/Bluray/HD-DVD discs have DRM copy protection. According to DMCA breaking 
the encryption is illegal. Online shops only rent the same material. Software 
developers may need more space, but 99.9% of people are not software 
developers. Thus q.e.d, you don't need that much space.


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread domino
the retarded superretard script kid Wrote:

 Tue, 07 Sep 2010 05:45:55 +, BCS wrote:
 
  Hello Nick,
  
  BCS n...@anon.com wrote in message
  news:a6268ff1b9958cd1bfa01297...@news.digitalmars.com...
  
  Hello Nick,
  
  Ugh, don't even get me started on MicroSD. Ordinary SD is already too
  small if you ask me, although I still put up with it anyway. Now
  MicroSD, well I can't say anything about it without raising my blood
  pressure...
  
  My point was that space (volume) is not what limits how much space
  (GB) a phone has.
  
  And my link dispelled that myth. Try putting 200GB+ into a MicroSD form
  factor at the cost of a 2.5 HDD. Yea, eventually that'll happen, but
  by then I could get a HDD many times bigger than that for the same
  price.
  
  
  I wouldn't. I'd put it in a package about 4-5 times as big and mount it
  on the PC board. Besides, what the heck do you need more than about 32GB
  for on a phone? If you need to shoot that much video, get a real camera!
 
 I have 32 GB micro-sdhc cards (class 2 or 4) on my phone and 64 GB 
 compactflash (don't know the class, but approximately 90 MB/s) on my 
 camera (Canon 7D). Both could have more space. The camera doesn't compress 
 video very well despite quite high price so the maximum video length is 
 only few minutes.

I doubt that. The only camera you have is in your phone. VGA 640x480 quality

 
  
  Besides:
  http://www.microcenter.com/search/search_results.phtml?N=4294966955+
  42 94953566sht=Anyprt=NewProduct
  
  If I wanted more sortage than I can put on flash cards, I'd breing a
  lap-top. OTOH: this is the class of phone I use:
  http://www.motorola.com/Consumers/US-EN/Consumer-Product-and-Services
  /Mobile-Phones/Motorola-Stature-i9-US-EN
  
  You're not everyone. Some people would rather have HDD-level storage
  capacity.
  
  
  1) I don't want an HDD in my phone. Moving parts? Ouch! 2) That will
  always be cheaper as an external HDD. Some people will want to use their
  phone as a weapon, should that also be a design criteria?
 
 I'd like to have 128..512 GB of storage in the phone. Why? My media 
 library (hundreds of CDs  DVDs transcoded - mp3/ogg or xvid). I think 
 this is even possible with two 64 GB sdxc cards. Podcasts. TV series. 
 Games. Photos converted to JPG @ 1080p resolution for powerpoint  other 
 purposes.

Yep yep.. piratebay kid. Your first year CS 101 teacher doesn't expect any 
powerpoints from a people of your quality.

 
  
  In this day and age, you would be hard pressed to suggest a smart
  phone/PDA needs more than a 1 maybe 2 USB ports. You might, just
  maybe, talk me into believing that an HDMI port could be handy. But
  that would really push it.
  
  Ugh, I hate HDMI, but that's a whole other discussion ;)
  
  
  I just picked the smallest video connector I could think of.
 
 The mini-HDMI is pretty decent. There are no better alternatives that I 
 know of at the moment. 1080p video + multichannel audio, quite small.

Firewire. Nuff said

 
 My phone  cam both also have micro-usb 2.0 connectors. Pretty good. 
 Waiting for usb 3.0.

Your _phone_ has usb 1.0 and a proprietary connector. 


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread Walter Bright

BCS wrote:
People want a phone that has a key board from the get go. How many 
people actually want to /add/ one to the phone they have?



I like being able now and then to attach a full size keyboard.


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread Walter Bright

domino wrote:

Ordinary man cannot have 5 TB of data because ALL standard movie/audio
CD/DVD/Bluray/HD-DVD discs have DRM copy protection.


CDs are not copy protected.

I'm running around .5 TB these days, and none of it is DRM'd material. (Family 
movies eat up space like you wouldn't believe, too.)


Re: [OT] Use case for a 4-D matrix

2010-09-07 Thread Tomek Sowiński

Dnia 04-09-2010 o 08:03:12 John Demme j...@cs.columbia.edu napisał(a):


As for the graphs, I essentially take two input graphs, represented in
adjacency matrix form (two 2-d matrices of size n^2 each, assuming equal
sized graphs).  Then, I compute the Kronecker Tensor Graph Product[2],  
which

creates a matrix of size n^4.  Depending on how you think about it, this
matrix is a simple (although large) 2-D adjacency matrix of the product
graph, and it can be treated as such for many operations.  It can also be
inspected in four dimensional space to examine the relationships between
possible node pairs, but I don't do this.  Frankly, it hurts my brain a
little bit.


Can't you compute the Kronecker product lazily? E.g. a proxy object that  
computes a value in an overloaded opIndex. Even if your algorithms inspect  
(compute) the same value several times, you may still win -- the  
bottleneck these days is memory access, not CPU cycles.


Fascinating stuff you're dealing with... Good luck.

Tomek


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread domino
Walter Bright Wrote:

 domino wrote:
  Ordinary man cannot have 5 TB of data because ALL standard movie/audio
  CD/DVD/Bluray/HD-DVD discs have DRM copy protection.
 
 CDs are not copy protected.

False.

I have 10--20 discs with cactus data protection. Two with sony bmg rootkit 
protection system. And several with mediamax protection. At least the cactus 
shit is annoying. They corrupted the audio on purpose and it's audible even 
with a legal authentic cd audio player. If you place these discs in a standard 
PC cd/dvd drive, it just spins and spins and spins and spins and the OS either 
hangs or refuses to open the cd tray. I'm 100% sure you are not allowed to 
break these.


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread Nick Sabalausky
domino eff...@sitemine.org wrote in message 
news:i666vt$158...@digitalmars.com...
 Walter Bright Wrote:

 domino wrote:
  Ordinary man cannot have 5 TB of data because ALL standard movie/audio
  CD/DVD/Bluray/HD-DVD discs have DRM copy protection.

 CDs are not copy protected.

 False.

 I have 10--20 discs with cactus data protection. Two with sony bmg rootkit 
 protection system. And several with mediamax protection. At least the 
 cactus shit is annoying. They corrupted the audio on purpose and it's 
 audible even with a legal authentic cd audio player. If you place these 
 discs in a standard PC cd/dvd drive, it just spins and spins and spins and 
 spins and the OS either hangs or refuses to open the cd tray. I'm 100% 
 sure you are not allowed to break these.

The vast majority of CDs don't have that. I have approx 250 commercial audio 
CDs, and not a single one of them has any DRM. And if I did want something 
that only came on a DRMed CD, I'd just say Fuck you Sony and pirate it. 




D1/D2: How to check if a method has been overridden

2010-09-07 Thread klickverbot

Hello all,

as some of you might know, I have started working on a D module for SWIG 
quite some time ago. In the meantime, the project is almost ready for 
inclusion in SWIG trunk as a full-fledged language module supporting 
D1/Tango and D2/Phobos.


However, there is one major blocker left: I need to check if a method 
has been overridden for this in a potential subclass (obviously at 
runtime), as illustrated below.


---
class A {
  void foo( float a ) {}
  void foo( int a ) {}

  final void bar() {
// Determine whether this.foo( 1 ) and this.foo( 1f ) really refer
// to A.foo( float ) and A.foo( int ) or if they point to a subclass
// implementation – how?
  }
}

class B : A {
  override void foo( float a ) {}
}

class C : A {
  override void foo( int a ) {}
}

class D : B {
  override void foo( int a ) {}
}
---

Until DMD 1.047, I have used a piece of code shown in 
http://d.puremagic.com/issues/show_bug.cgi?id=4835, but the casts in 
there are no longer enough for DMD to determine which overload is being 
referred to.


Now, please tell me that there _is_ a way to do this (D1 and D2, but I 
don't mind if have to generate different code for the both)…


Re: D1/D2: How to check if a method has been overridden

2010-09-07 Thread Mafi

Am 07.09.2010 23:00, schrieb klickverbot:

Hello all,

as some of you might know, I have started working on a D module for SWIG
quite some time ago. In the meantime, the project is almost ready for
inclusion in SWIG trunk as a full-fledged language module supporting
D1/Tango and D2/Phobos.

However, there is one major blocker left: I need to check if a method
has been overridden for this in a potential subclass (obviously at
runtime), as illustrated below.

---
class A {
void foo( float a ) {}
void foo( int a ) {}

final void bar() {
// Determine whether this.foo( 1 ) and this.foo( 1f ) really refer
// to A.foo( float ) and A.foo( int ) or if they point to a subclass
// implementation – how?
}
}

class B : A {
override void foo( float a ) {}
}

class C : A {
override void foo( int a ) {}
}

class D : B {
override void foo( int a ) {}
}
---

Until DMD 1.047, I have used a piece of code shown in
http://d.puremagic.com/issues/show_bug.cgi?id=4835, but the casts in
there are no longer enough for DMD to determine which overload is being
referred to.

Now, please tell me that there _is_ a way to do this (D1 and D2, but I
don't mind if have to generate different code for the both)…


Hi,
couldn't you just check if a delegate's funcptr is the same as the real 
funcptr:

 this.foo == foo
I'm not sure if the right isn't an shortcut for the left and it could 
get weird with strange linking but if D really want's to be a system's 
language then this should work.


Mafi


Re: D1/D2: How to check if a method has been overridden

2010-09-07 Thread klickverbot

On 9/7/10 11:12 PM, dsimcha wrote:

One way to test for overriding at runtime is to compare the function pointer of 
a
delegate obtained at runtime to the function pointer obtained from the compile
time type.


That's basically the same idea I were already using, but have you tried 
implementing it for overloaded functions? I have not gotten this to work 
since there is seemingly no way to do a.foo then.


Re: D1/D2: How to check if a method has been overridden

2010-09-07 Thread dsimcha
One way to test for overriding at runtime is to compare the function pointer of 
a
delegate obtained at runtime to the function pointer obtained from the compile
time type.

Here's a simplified example:

import std.stdio;

class A {
void fun() {}
}

class B : A {
override void fun() {}
}

void main() {
auto a = new A;
auto b = new B;

auto aDel = a.fun;
auto bDel = b.fun;

writeln(A.fun is aDel.funcptr);  // True:  fun is not overridden
writeln(A.fun is bDel.funcptr);  // False:  fun is overridden
}


Re: D1/D2: How to check if a method has been overridden

2010-09-07 Thread klickverbot

On 9/7/10 11:07 PM, Mafi wrote:

I'm not sure if the right isn't an shortcut for the left […]


Unfortunately, the right indeed is a shortcut for the left – the lookup 
is performed using the vtbl. Furthermore, this would not solve my 
problem with overloaded functions.


Re: D1/D2: How to check if a method has been overridden

2010-09-07 Thread dsimcha
== Quote from klickverbot (s...@klickverbot.at)'s article
 On 9/7/10 11:12 PM, dsimcha wrote:
  One way to test for overriding at runtime is to compare the function 
  pointer of a
  delegate obtained at runtime to the function pointer obtained from the 
  compile
  time type.
 That's basically the same idea I were already using, but have you tried
 implementing it for overloaded functions? I have not gotten this to work
 since there is seemingly no way to do a.foo then.

All you need to do is provide an explicit type for the delegate:

class A {
void fun(uint num) {}
void fun(float num) {}
}

void main() {
auto a = new A;
void delegate(float) funDel = a.fun;
}



Re: D1/D2: How to check if a method has been overridden

2010-09-07 Thread bearophile
klickverbot:

 class A {
void foo( float a ) {}
void foo( int a ) {}
 
final void bar() {
  // Determine whether this.foo( 1 ) and this.foo( 1f ) really refer
  // to A.foo( float ) and A.foo( int ) or if they point to a subclass
  // implementation – how?
}
 }
 
 class B : A {
override void foo( float a ) {}
 }
 
 class C : A {
override void foo( int a ) {}
 }
 
 class D : B {
override void foo( int a ) {}
 }

Have you tried to compile that code with -w?
See also:
http://d.puremagic.com/issues/show_bug.cgi?id=4216

Bye,
bearophile


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread Walter Bright

Nick Sabalausky wrote:
The vast majority of CDs don't have that. I have approx 250 commercial audio 
CDs, and not a single one of them has any DRM. And if I did want something 
that only came on a DRMed CD, I'd just say Fuck you Sony and pirate it. 


I have around 400 CDs, and also exactly zero of them have any form of DRM on 
them. I ripped them with Windows Media Player, not exactly a cracking tool.


Re: D1/D2: How to check if a method has been overridden

2010-09-07 Thread klickverbot

On 9/7/10 11:31 PM, bearophile wrote:

Have you tried to compile that code with -w?
See also:
http://d.puremagic.com/issues/show_bug.cgi?id=4216

Bye,
bearophile


Well, I guess I should have wrote the following instead:

---
class A {
   void foo( float a ) {}
   void foo( int a ) {}

   final void bar() {
 // Determine whether this.foo( 1 ) and this.foo( 1f ) really refer
 // to A.foo( float ) and A.foo( int ) or if they point to a subclass
 // implementation – how?
   }
}

class B : A {
   alias A.foo foo;
   override void foo( float a ) {}
}

class C : A {
   alias A.foo foo;
   override void foo( int a ) {}
}

class D : B {
   alias B.foo foo;
   override void foo( int a ) {}
}
---


Re: D1/D2: How to check if a method has been overridden

2010-09-07 Thread klickverbot

s/have wrote/have written/


Re: D1/D2: How to check if a method has been overridden

2010-09-07 Thread klickverbot
Putting the overloading issue aside for a moment, how would you 
implement it inside a member function of a (which is required for 
various reasons?


The following does *not* work, because A.foo also performs a vtbl 
lookup when put inside A…


---
class A {
void foo() {}
void bar() {
   auto thisDg = this.foo;
   writeln(A.foo is thisDg.funcptr);
}
}
---

Besides, it also returns a delegate because of this, which is why the 
code does not even compile, but that would be worked around easily.


Re: D1/D2: How to check if a method has been overridden

2010-09-07 Thread Jason House
That looks like something that should go into bugzilla.

klickverbot Wrote:

 Putting the overloading issue aside for a moment, how would you 
 implement it inside a member function of a (which is required for 
 various reasons?
 
 The following does *not* work, because A.foo also performs a vtbl 
 lookup when put inside A…
 
 ---
 class A {
  void foo() {}
  void bar() {
 auto thisDg = this.foo;
 writeln(A.foo is thisDg.funcptr);
  }
 }
 ---
 
 Besides, it also returns a delegate because of this, which is why the 
 code does not even compile, but that would be worked around easily.



[OT]: Google AI Challenge: starter package for D

2010-09-07 Thread Seth Hoenig
On Friday (Sept. 10), Google/The University of Waterloo is going to open up
registration for the next Google AI Challenge. Right now they are accepting
starter packages for any language with a free compiler that can run on
Ubuntu 8.04 (what their server runs), which means dmd is a candidate. I have
already gotten a sort-of thumbs up from the contest organizer on getting
them to host D as a language[1], and this evening I put together a starter
package[2].

However, I am still very much a novice with D, so I was hoping some of you
experts could take a look at the code and give some suggestions,
particularly regarding performance enhancements. Each bot is allowed 1
second of calculation time per turn, and doing file IO haphazardly like I do
is probably eating up a lot of that time. The files in question are the ones
ending in .d; everything else just behind the scenes stuff that doesn't
change.


[1] http://ai-contest.com/forum/viewtopic.php?f=18t=423
[2] http://bitbucket.org/Queue29/d_starter_package/src



Seth Hoenig
seth.a.hoe...@gmail.com


Re: [Slight OT] TDPL in Russia

2010-09-07 Thread BCS

Hello domino,


Walter Bright Wrote:


domino wrote:


Ordinary man cannot have 5 TB of data because ALL standard
movie/audio CD/DVD/Bluray/HD-DVD discs have DRM copy protection.


CDs are not copy protected.


False.

I have 10--20 discs with cactus data protection. Two with sony bmg
rootkit protection system. And several with mediamax protection. At
least the cactus shit is annoying. They corrupted the audio on purpose
and it's audible even with a legal authentic cd audio player. If you
place these discs in a standard PC cd/dvd drive, it just spins and
spins and spins and spins and the OS either hangs or refuses to open
the cd tray. I'm 100% sure you are not allowed to break these.



I've never owned a CD player that wasn't a CD-ROM drive. I've never come 
across a disk I couldn't play.


--
... IXOYE





Re: [Slight OT] TDPL in Russia

2010-09-07 Thread BCS

Hello Nick,


domino eff...@sitemine.org wrote in message
news:i666vt$158...@digitalmars.com...


Walter Bright Wrote:


domino wrote:


Ordinary man cannot have 5 TB of data because ALL standard
movie/audio CD/DVD/Bluray/HD-DVD discs have DRM copy protection.


CDs are not copy protected.


False.

I have 10--20 discs with cactus data protection. Two with sony bmg
rootkit protection system. And several with mediamax protection. At
least the cactus shit is annoying. They corrupted the audio on
purpose and it's audible even with a legal authentic cd audio player.
If you place these discs in a standard PC cd/dvd drive, it just spins
and spins and spins and spins and the OS either hangs or refuses to
open the cd tray. I'm 100% sure you are not allowed to break these.


The vast majority of CDs don't have that. I have approx 250 commercial
audio CDs, and not a single one of them has any DRM. And if I did want
something that only came on a DRMed CD, I'd just say Fuck you Sony
and pirate it.



I'd buy the disk, put it on the shelf and let it collect dust with the rest 
and download the tracks I really care about.

--
... IXOYE





Re: [Slight OT] TDPL in Russia

2010-09-07 Thread BCS

Hello retard,


Tue, 07 Sep 2010 05:45:55 +, BCS wrote:


I wouldn't. I'd put it in a package about 4-5 times as big and mount
it on the PC board. Besides, what the heck do you need more than
about 32GB for on a phone? If you need to shoot that much video, get
a real camera!


I have 32 GB micro-sdhc cards (class 2 or 4) on my phone and 64 GB
compactflash (don't know the class, but approximately 90 MB/s) on my
camera (Canon 7D). Both could have more space. The camera doesn't
compress video very well despite quite high price so the maximum video
length is only few minutes.



Real cameras are another matter. A good lens alone is bigger than a 2.5 HDD.


You're not everyone. Some people would rather have HDD-level storage
capacity.


1) I don't want an HDD in my phone. Moving parts? Ouch! 2) That will
always be cheaper as an external HDD. Some people will want to use
their phone as a weapon, should that also be a design criteria?


I'd like to have 128..512 GB of storage in the phone. Why? My media
library (hundreds of CDs  DVDs transcoded - mp3/ogg or xvid). I
think this is even possible with two 64 GB sdxc cards. Podcasts. TV
series. Games. Photos converted to JPG @ 1080p resolution for
powerpoint  other purposes.


Once you scratch into the I-might-want-it space, you can blow right past 
any reasonable amount of storage for a package you will like putting in your 
pocket.


--
... IXOYE





Troll

2010-09-07 Thread BCS






Re: forks/pipes and std.socket

2010-09-07 Thread Masahiro Nakagawa

On Mon, 06 Sep 2010 05:32:28 +0900, Nick Sabalausky a...@a.a wrote:


This may be a stupid question:

Does std.socket encorporate or replace pipe usage? Ie, if I'm going to do
something along the lines of (psuedo-code):

auto parentToChild = pipe();
auto childToParent = pipe();
if(fork())
{
// talk to other process
}
else
{
// talk to other process
}

Is there anything in std.socket, or any way of using it that would aid in
this sort of thing (ideally in a cross-platform way), or is it entirely
orthogonal to this?

Does anyone who's done this sort of thing in D before, on Win or Lin,  
know

of anything else in particular to be aware of?




Unix domain socket?

http://lists.puremagic.com/pipermail/phobos/2010-July/001171.html

This socket I rewrote can communicate with other processes using  
LocalEndpoint.

(Sorry, I don't know Windows environment).


Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Jacob Carlborg

On 2010-09-07 14:49, Steven Schveighoffer wrote:

On Sun, 05 Sep 2010 09:40:59 -0400, BLS windev...@hotmail.de wrote:


On 05/09/2010 02:16, Jonathan M Davis wrote:

void foo(T)(T[] collection, T elem)

{
// Blah, whatever
}



I am curious, how this will look and feel once inout is working ?

inout void foo(T)(inout(T)[] collection, inout T elem)
{
// Blah, whatever}
}



inout void doesn't make any sense. You can't have a const void or
immutable void.

Now, if foo is a member function, then inout applies to the this
pointer, but even then, you need a return type other than void for inout
to be used.

-Steve


inout is only used when you want to return the same constness (mutable, 
const, immutable) as you passed in to the function. If you don't want 
that, or don't want to return anything then const(T)[] is what you want. 
It will accept mutable, const and immutable.


--
/Jacob Carlborg


Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread Steven Schveighoffer
On Sun, 05 Sep 2010 22:41:50 -0400, bearophile bearophileh...@lycos.com  
wrote:



Tom Kazimiers:

How can I have a (temporary) dynamic array on stack and make references
to it (no copying)? I successively put integers in an array (but don't
know how much there will be in advance) with an appender!(int[]) and get
the date out with appender.data(). Later on I pass the result to a
method as an in int[] parameter. Is that already a reference or will
it be copied? Are there better methods to accomplish this? The method
receiving such an array will not modifiy contents of the array, but only
read from it.


The appender.data() doesn't currently copy data.

There is no standard way to put a growable array on the stack. Maybe you  
can hack it with several successive calls to alloca(), but I have never  
tried it.


Hm... you can do something like this (after upcoming release, appender has  
changed):


void foo()
{
   int[1024] buf;
   auto app = appender(buf[]);
   app.clear();
   ...
}

After app.clear, appender will fill up the static buffer until full, and  
then reallocate on the heap.


Note that the new appender uses heap data to store its implementation, so  
it's not as quick as it could be.  This is per Andrei's requirement that  
it be a reference type.


-Steve


Question about typeof(this)

2010-09-07 Thread Jacob Carlborg
I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof 
where it says:


typeof(this) will generate the type of what this  would be in a 
non-static member function, even if not in a member function. 


From that I got the impression that the code below would print the same 
result, but it doesn't. It prints:


main.Bar
main.Foo

instead of:

main.Foo
main.Foo

Is this a bug or have I misunderstood the docs?


module main;

import std.stdio;

class Bar
{
void method ()
{
writeln(typeid(typeof(this)));
writeln(typeid(this));
}
}

class Foo : Bar {}

void main ()
{
auto foo = new Foo;
foo.method;
}

--
/Jacob Carlborg


Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Steven Schveighoffer

On Tue, 07 Sep 2010 08:56:15 -0400, Jacob Carlborg d...@me.com wrote:


On 2010-09-07 14:49, Steven Schveighoffer wrote:

On Sun, 05 Sep 2010 09:40:59 -0400, BLS windev...@hotmail.de wrote:


On 05/09/2010 02:16, Jonathan M Davis wrote:

void foo(T)(T[] collection, T elem)

{
// Blah, whatever
}



I am curious, how this will look and feel once inout is working ?

inout void foo(T)(inout(T)[] collection, inout T elem)
{
// Blah, whatever}
}



inout void doesn't make any sense. You can't have a const void or
immutable void.

Now, if foo is a member function, then inout applies to the this
pointer, but even then, you need a return type other than void for inout
to be used.

-Steve


inout is only used when you want to return the same constness (mutable,  
const, immutable) as you passed in to the function. If you don't want  
that, or don't want to return anything then const(T)[] is what you want.  
It will accept mutable, const and immutable.


Yes, exactly.  This is why inout functions cannot return void.

-Steve


Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Pelle

On 09/07/2010 03:15 PM, Steven Schveighoffer wrote:

On Tue, 07 Sep 2010 08:56:15 -0400, Jacob Carlborg d...@me.com wrote:


On 2010-09-07 14:49, Steven Schveighoffer wrote:

On Sun, 05 Sep 2010 09:40:59 -0400, BLS windev...@hotmail.de wrote:


On 05/09/2010 02:16, Jonathan M Davis wrote:

void foo(T)(T[] collection, T elem)

{
// Blah, whatever
}



I am curious, how this will look and feel once inout is working ?

inout void foo(T)(inout(T)[] collection, inout T elem)
{
// Blah, whatever}
}



inout void doesn't make any sense. You can't have a const void or
immutable void.

Now, if foo is a member function, then inout applies to the this
pointer, but even then, you need a return type other than void for inout
to be used.

-Steve


inout is only used when you want to return the same constness
(mutable, const, immutable) as you passed in to the function. If you
don't want that, or don't want to return anything then const(T)[] is
what you want. It will accept mutable, const and immutable.


Yes, exactly. This is why inout functions cannot return void.

-Steve


Hmm.

class C {
void foo(void delegate(inout(C)) f) inout {
f(this);
}
}

Am I missing something?


Pop an element from an array inplace?

2010-09-07 Thread Paolo Invernizzi
Hi all,

What's the best way to find an element into an array, drop it and shrink the 
array inplace, in D2?

Thanks in advance, Paolo


Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Steven Schveighoffer

On Tue, 07 Sep 2010 09:28:18 -0400, Pelle pelle.mans...@gmail.com wrote:


On 09/07/2010 03:15 PM, Steven Schveighoffer wrote:

On Tue, 07 Sep 2010 08:56:15 -0400, Jacob Carlborg d...@me.com wrote:


On 2010-09-07 14:49, Steven Schveighoffer wrote:

On Sun, 05 Sep 2010 09:40:59 -0400, BLS windev...@hotmail.de wrote:


On 05/09/2010 02:16, Jonathan M Davis wrote:

void foo(T)(T[] collection, T elem)

{
// Blah, whatever
}



I am curious, how this will look and feel once inout is working ?

inout void foo(T)(inout(T)[] collection, inout T elem)
{
// Blah, whatever}
}



inout void doesn't make any sense. You can't have a const void or
immutable void.

Now, if foo is a member function, then inout applies to the this
pointer, but even then, you need a return type other than void for  
inout

to be used.

-Steve


inout is only used when you want to return the same constness
(mutable, const, immutable) as you passed in to the function. If you
don't want that, or don't want to return anything then const(T)[] is
what you want. It will accept mutable, const and immutable.


Yes, exactly. This is why inout functions cannot return void.

-Steve


Hmm.

class C {
 void foo(void delegate(inout(C)) f) inout {
 f(this);
 }
}

Am I missing something?


Yes, a valid return.  Your function should be:

void foo(void delegate(const(C) f) const

It helps to understand that inout/const/immutable has NOTHING to do with  
code generation, it only has to do with limiting what compiles.  For this  
reason, an inout function is compiled once, and works on all three  
constancies (4 if you have a nested inout function).  For the entire  
function any inout variable is treated as a non-changeable value, just  
like const.  Then when you return, it's converted at the call site back to  
the constancy with which it was called.  If the return value is void, then  
there's nothing to convert, and no reason to use inout over const.


I'll repeat -- there is no benefit to inout if you are not returning  
anything.


-Steve


Re: Question about typeof(this)

2010-09-07 Thread Don

Jacob Carlborg wrote:
I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof 
where it says:


typeof(this) will generate the type of what this  would be in a 
non-static member function, even if not in a member function. 


 From that I got the impression that the code below would print the same 
result, but it doesn't. It prints:


main.Bar
main.Foo

instead of:

main.Foo
main.Foo

Is this a bug or have I misunderstood the docs?


typeof(this) gives the *compile-time* type of this. Inside Bar, it has 
to return 'Bar'.
typeid(this) gives the *runtime* type of this. So it can work that it's 
Bar is actually a Foo.






module main;

import std.stdio;

class Bar
{
void method ()
{
writeln(typeid(typeof(this)));
writeln(typeid(this));
}
}

class Foo : Bar {}

void main ()
{
auto foo = new Foo;
foo.method;
}



Re: Question about typeof(this)

2010-09-07 Thread Stanislav Blinov

 07.09.2010 17:00, Jacob Carlborg пишет:
I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof 
where it says:


typeof(this) will generate the type of what this would be in a 
non-static member function, even if not in a member function. 


From that I got the impression that the code below would print the 
same result, but it doesn't. It prints:


main.Bar
main.Foo

instead of:

main.Foo
main.Foo

Is this a bug or have I misunderstood the docs?


module main;

import std.stdio;

class Bar
{
void method ()
{
writeln(typeid(typeof(this)));
writeln(typeid(this));
}
}

class Foo : Bar {}

void main ()
{
auto foo = new Foo;
foo.method;
}

I don't think it's a bug. More of it, Expressions page in the docs has 
your very same example in Typeid section.


Inside Bar.method, typeof(this) yields a type (Bar), and typeid for 
types gets you, well, typeid for types :) typeid(this), hovewer, should 
get typeinfo for most derived class, which it does.


Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Pelle

On 09/07/2010 04:33 PM, Steven Schveighoffer wrote:

Yes, a valid return. Your function should be:

void foo(void delegate(const(C) f) const

It helps to understand that inout/const/immutable has NOTHING to do with
code generation, it only has to do with limiting what compiles. For this
reason, an inout function is compiled once, and works on all three
constancies (4 if you have a nested inout function). For the entire
function any inout variable is treated as a non-changeable value, just
like const. Then when you return, it's converted at the call site back
to the constancy with which it was called. If the return value is void,
then there's nothing to convert, and no reason to use inout over const.

I'll repeat -- there is no benefit to inout if you are not returning
anything.

-Steve


That's not an equivalent function signature. Or maybe it is, but look at 
this (sorry it's so long):


class C {
int x;
this(int y) { x = y; }

inout(int*) foo() inout {
return x;
}
void bar(void delegate(int*) f) {
f(x);
}
void bar(void delegate(const(int*)) f) const {
f(x);
}
void bar(void delegate(immutable(int*)) f) immutable {
f(x);
}
}

void main() {

immutable(int)* wah;
void wahwah(immutable(int*) x) {
wah = x;
}
auto c = new immutable(C)(10);
wahwah(c.foo);  // why is this privilegied with inout
c.bar(wahwah); // and this not?

writeln(*wah);

}

Can't use void delegate(const(int*)) there.


Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread Tom Kazimiers
Hi,

thanks for your tests.

On 09/06/2010 04:59 AM, bearophile wrote:
 My first test shows that it may work. But I have to grow the array
 backwards, and push back the array start, because that's how my stack
 grows (using alloca to allocate geometrically bigger chunks). So
 unless you want to reverse the items once the array is built, you
 have to change the algorithm that uses the array a little.

Unfortunately I need the elements to stay in the order I have added
them. But good to know that it would work with backward growing of the
array - do have you an example of that?

Cheers,
Tom


Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread bearophile
Steven Schveighoffer:
 Note that the new appender uses heap data to store its implementation, so  
 it's not as quick as it could be.  This is per Andrei's requirement that  
 it be a reference type.

Thank you for your answers. But I don't fully understand your answer. Do you 
mean it uses the Pimpl idiom, and allocates the struct on the heap?

I use appender only when performance is important. The appender is a hack 
useful because array appending in D is very slow (and even appender is quite 
slow), so it must be first of all fast, otherwise it's not useful.

I generally use appender inside the scope of a single function.

So unless I am missing something I think Andrei requirement is/was wrong.

Bye,
bearophile


Re: Pop an element from an array inplace?

2010-09-07 Thread bearophile
Paolo Invernizzi:
 What's the best way to find an element into an array, drop it and shrink  
 the array inplace, in D2?

Inside the module std.array there is a commented out function that allows to 
remove items. I don't know why it is commented out, maybe there is some bug.

You can find the index with the indexOf().
Then if your items don't have a postblit (and you can test for that), then you 
may just need std.c.string.memmove to shift the items.
If the items are structs with a postblit, then I presume the best thing you can 
do is to copy each item in a normal loop.
After that static if, you decrease the array length by 1, and return the item 
saved in a temporary variable.

--

Simen kjaeraas:
 T extract( T )( ref T[] haystack, const T element ) {
  auto loc = indexOf( haystack, element );
  T result = haystack[loc];
  haystack = haystack[0..loc] ~ haystack[loc+1..$];
  return result;
 }

It's not in-place, as requested by Paolo.

Bye,
bearophile


Input Scanning

2010-09-07 Thread Max Mayrhofer
Hi all, I have what is I suspect a silly question, but I am having a
total brainfart over this for some reason.  I want to read an
arbitrary amount of floats from user input and then perform some
statistics work on them. For some reason, I can't figure out how to
get it to recognise when the user has stopped entering values.  My
current code is:

void main(string[] args) {
Stat[] stats;
foreach (arg; args[1 .. $]) {
auto newStat = cast(Stat) Object.factory(main. ~
arg);
enforce(newStat, Invalid statistics function:  ~
arg);
stats ~= newStat;
}
for (double x; stdin.readf( %s , x) == 1; ) {
foreach (s; stats) {
s.accumulate(x);
}
}
foreach (s; stats) {
s.postprocess();
writeln(s.result());
}
}

At the moment it just crashes with a conversion error when invoked,
for example, with:

echo 3 1.6 17 | stats Min Average

I know my problem is the readf, but what would best practice be for
this situation?


DMD2 does not link on windows 7-64bit

2010-09-07 Thread %u
I get the following strange message when linking:
==
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 23: No Stack
first.obj(first)
 Error 42: Symbol Undefined _D3std5stdio6stdoutS3std5stdio4File
first.obj(first)
 Error 42: Symbol Undefined _fprintf
first.obj(first)
 Error 42: Symbol Undefined _D3std9exception7bailOutFAyaixAaZv
first.obj(first)
 Error 42: Symbol Undefined _D3std5stdio12__ModuleInfoZ
first.obj(first)
 Error 42: Symbol Undefined _D6object6Object8opEqualsMFC6ObjectC6ObjectZb
first.obj(first)
 Error 42: Symbol Undefined _D6object6Object8opEqualsMFC6ObjectZb
first.obj(first)
 Error 42: Symbol Undefined _D6object6Object5opCmpMFC6ObjectZi
first.obj(first)
 Error 42: Symbol Undefined _D6object6Object6toHashMFZk
first.obj(first)
 Error 42: Symbol Undefined _D6object6Object8toStringMFZAya
first.obj(first)
 Error 42: Symbol Undefined _D6Object7__ClassZ
first.obj(first)
 Error 42: Symbol Undefined _D14TypeInfo_Class6__vtblZ
OPTLINK : Warning 134: No Start Address
--- errorlevel 11
==
I simply call dmd first.d where first.d contains a small class definition

Still, there is a resulting  executable final.exe.
When running it, I get a windows message telling me that
the application is not 64-Bit compatible

regards,
Oliver


Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Steven Schveighoffer

On Tue, 07 Sep 2010 11:37:20 -0400, Pelle pelle.mans...@gmail.com wrote:


On 09/07/2010 04:33 PM, Steven Schveighoffer wrote:

Yes, a valid return. Your function should be:

void foo(void delegate(const(C) f) const

It helps to understand that inout/const/immutable has NOTHING to do with
code generation, it only has to do with limiting what compiles. For this
reason, an inout function is compiled once, and works on all three
constancies (4 if you have a nested inout function). For the entire
function any inout variable is treated as a non-changeable value, just
like const. Then when you return, it's converted at the call site back
to the constancy with which it was called. If the return value is void,
then there's nothing to convert, and no reason to use inout over const.

I'll repeat -- there is no benefit to inout if you are not returning
anything.

-Steve


That's not an equivalent function signature. Or maybe it is, but look at  
this (sorry it's so long):


class C {
 int x;
 this(int y) { x = y; }

 inout(int*) foo() inout {
 return x;
 }
 void bar(void delegate(int*) f) {
 f(x);
 }
 void bar(void delegate(const(int*)) f) const {
 f(x);
 }
 void bar(void delegate(immutable(int*)) f) immutable {
 f(x);
 }
}

void main() {

 immutable(int)* wah;
 void wahwah(immutable(int*) x) {
 wah = x;
 }
 auto c = new immutable(C)(10);
 wahwah(c.foo);  // why is this privilegied with inout
 c.bar(wahwah); // and this not?

 writeln(*wah);

}

Can't use void delegate(const(int*)) there.


Thanks for clarifying, I didn't quite understand the usage before.

This is a limitation of inout's design.  Technically inout requires a  
single inout output, and can have multiple inout inputs.  Your example  
matches that description, so in theory it's possible.


But to simplify things, a function's only inout output must be on the  
return value.  So things like void fn(inout int* x, out inout(int) y)  
don't qualify either.


IMO there is a whole host of implicit delegate casting that should be  
possible, but isn't, including delegate contravariance.  However, let's  
get inout working as it's currently designed before we go relaxing the  
requirements.  I'm not a compiler/language designer, so I'm unsure if what  
you want has any pitfalls.


-Steve


Re: DMD2 does not link on windows 7-64bit

2010-09-07 Thread OK
To answer my own post :
the problems vanish when I add a main() method.
question : how do I automagically add a standard main method ?

regards, Oliver


Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread Steven Schveighoffer
On Tue, 07 Sep 2010 12:54:52 -0400, bearophile bearophileh...@lycos.com  
wrote:



Steven Schveighoffer:
Note that the new appender uses heap data to store its implementation,  
so

it's not as quick as it could be.  This is per Andrei's requirement that
it be a reference type.


Thank you for your answers. But I don't fully understand your answer. Do  
you mean it uses the Pimpl idiom, and allocates the struct on the heap?


Yes.

I use appender only when performance is important. The appender is a  
hack useful because array appending in D is very slow (and even appender  
is quite slow), so it must be first of all fast, otherwise it's not  
useful.


Appending is as fast as possible, at the cost of an initial allocation.   
Without this, the capacity would have to be stored inside the array, or be  
aliased, which wouldn't work all that well.



I generally use appender inside the scope of a single function.

So unless I am missing something I think Andrei requirement is/was wrong.


An appender is an ouput range, so passing it into a function so the  
function can output to it is a requirement.


-Steve


Loading a C/C++ dll

2010-09-07 Thread OK
Hello again,

I know the extern(C) mechanism, but how do I actually load a C-dll
such that my D-program has access to the functions of the C/C++ dll.

regards,
Oliver


Re: Question about typeof(this)

2010-09-07 Thread Jacob Carlborg

On 2010-09-07 17:29, Don wrote:

Jacob Carlborg wrote:

I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof
where it says:

typeof(this) will generate the type of what this would be in a
non-static member function, even if not in a member function. 

From that I got the impression that the code below would print the
same result, but it doesn't. It prints:

main.Bar
main.Foo

instead of:

main.Foo
main.Foo

Is this a bug or have I misunderstood the docs?


typeof(this) gives the *compile-time* type of this. Inside Bar, it has
to return 'Bar'.
typeid(this) gives the *runtime* type of this. So it can work that it's
Bar is actually a Foo.


I know that typeof(this) is a compile time expression but in this case I 
think the compiler has all the necessary information at compile time. 
Note that I'm not calling method on a base class reference, I'm 
calling it on the static type Foo. In this case I think typeof(this) 
would resolve to the type of the receiver, i.e. the type offoo.







module main;

import std.stdio;

class Bar
{
void method ()
{
writeln(typeid(typeof(this)));
writeln(typeid(this));
}
}

class Foo : Bar {}

void main ()
{
auto foo = new Foo;
foo.method;
}




--
/Jacob Carlborg


Re: Question about typeof(this)

2010-09-07 Thread Jacob Carlborg

On 2010-09-07 17:34, Stanislav Blinov wrote:

07.09.2010 17:00, Jacob Carlborg пишет:

I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof
where it says:

typeof(this) will generate the type of what this would be in a
non-static member function, even if not in a member function. 

From that I got the impression that the code below would print the
same result, but it doesn't. It prints:

main.Bar
main.Foo

instead of:

main.Foo
main.Foo

Is this a bug or have I misunderstood the docs?


module main;

import std.stdio;

class Bar
{
void method ()
{
writeln(typeid(typeof(this)));
writeln(typeid(this));
}
}

class Foo : Bar {}

void main ()
{
auto foo = new Foo;
foo.method;
}


I don't think it's a bug. More of it, Expressions page in the docs has
your very same example in Typeid section.

Inside Bar.method, typeof(this) yields a type (Bar), and typeid for
types gets you, well, typeid for types :) typeid(this), hovewer, should
get typeinfo for most derived class, which it does.


No it's not the same example. In the example on the Expressions page 
typeid is used on the static type A with the dynamic type B. I have both 
the static and dynamic type Foo. I think in my example the compiler have 
all the necessary information at compile time and typeof(this) would 
resolve to the type of the receiver, i.e. the type of foo which is Foo.


--
/Jacob Carlborg


Re: Loading a C/C++ dll

2010-09-07 Thread Kagamin
OK Wrote:

 I know the extern(C) mechanism, but how do I actually load a C-dll
 such that my D-program has access to the functions of the C/C++ dll.
 
You just link to it, system loader will do actual loading for you automatically.


Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Jacob Carlborg

On 2010-09-07 17:37, Pelle wrote:

On 09/07/2010 04:33 PM, Steven Schveighoffer wrote:

Yes, a valid return. Your function should be:

void foo(void delegate(const(C) f) const

It helps to understand that inout/const/immutable has NOTHING to do with
code generation, it only has to do with limiting what compiles. For this
reason, an inout function is compiled once, and works on all three
constancies (4 if you have a nested inout function). For the entire
function any inout variable is treated as a non-changeable value, just
like const. Then when you return, it's converted at the call site back
to the constancy with which it was called. If the return value is void,
then there's nothing to convert, and no reason to use inout over const.

I'll repeat -- there is no benefit to inout if you are not returning
anything.

-Steve


That's not an equivalent function signature. Or maybe it is, but look at
this (sorry it's so long):

class C {
int x;
this(int y) { x = y; }

inout(int*) foo() inout {
return x;
}
void bar(void delegate(int*) f) {
f(x);
}
void bar(void delegate(const(int*)) f) const {
f(x);
}
void bar(void delegate(immutable(int*)) f) immutable {
f(x);
}
}

void main() {

immutable(int)* wah;
void wahwah(immutable(int*) x) {
wah = x;
}
auto c = new immutable(C)(10);
wahwah(c.foo); // why is this privilegied with inout
c.bar(wahwah); // and this not?

writeln(*wah);

}

Can't use void delegate(const(int*)) there.


That won't work, you can't have inout on return of a function without 
having inout for a least one parameter. The compiler can't know what to 
resolve inout to, mutable, immutable or const.


--
/Jacob Carlborg


Re: forks/pipes and std.socket

2010-09-07 Thread Nick Sabalausky
Kagamin s...@here.lot wrote in message 
news:i660qi$nu...@digitalmars.com...
 Nick Sabalausky Wrote:

 Does anyone who's done this sort of thing in D before, on Win or Lin, 
 know
 of anything else in particular to be aware of?

 There's no fork on windows. If you want a multithreaded server, it's 
 usually implemented with threads on windows.

That was just an example. CreateProcess/spawn/system are fine for my 
purposes. I'm just talking about creating a child process and communicating 
with it via pipes. 




Re: DMD2 does not link on windows 7-64bit

2010-09-07 Thread Mike Chaten
If you are trying to compile a library, add -lib to make it not require a
main method.

On Tue, Sep 7, 2010 at 2:12 PM, OK herrsauro...@lavabit.com wrote:

 To answer my own post :
 the problems vanish when I add a main() method.
 question : how do I automagically add a standard main method ?

 regards, Oliver



How to properly link with a windws .lib file

2010-09-07 Thread OK
hello,

now I have written some code in first.d and added some extern(C) functions in
externs.d. How do I compile and link everything with
extern.lib ?

regards, Oliver


Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread bearophile
Steven Schveighoffer:
 An appender is an ouput range, so passing it into a function so the  
 function can output to it is a requirement.

I see, that's useful. I will write a Pimp-less version of it, then (when I 
don't need a range, but just a local accumulator).

Thank you for your always gentle answers,
hugs,
bearophile


Re: How to properly link with a windws .lib file

2010-09-07 Thread Stanislav Blinov

OK wrote:

hello,

now I have written some code in first.d and added some extern(C) functions in
externs.d. How do I compile and link everything with
extern.lib ?

regards, Oliver


Recently there was a pretty thorough discussion about this:

http://www.digitalmars.com/d/archives/digitalmars/D/learn/Re_Can_t_get_D_calling_C_to_build._21318.html


Re: forks/pipes and std.socket

2010-09-07 Thread Steven Schveighoffer

On Tue, 07 Sep 2010 14:54:46 -0400, Nick Sabalausky a...@a.a wrote:


Kagamin s...@here.lot wrote in message
news:i660qi$nu...@digitalmars.com...

Nick Sabalausky Wrote:


Does anyone who's done this sort of thing in D before, on Win or Lin,
know
of anything else in particular to be aware of?


There's no fork on windows. If you want a multithreaded server, it's
usually implemented with threads on windows.


That was just an example. CreateProcess/spawn/system are fine for my
purposes. I'm just talking about creating a child process and  
communicating

with it via pipes.


The upcoming std.process changes will make this easy.

-Steve


Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread bearophile
Tom Kazimiers:
 But good to know that it would work with backward growing of the
 array - do have you an example of that?

Just created:


import std.stdio: writeln;
import std.c.stdlib: alloca;

void main() {
int n = 30;
alias int T;
enum int initialCapacity = 4;
static assert(initialCapacity  0);

int len = 0;
int capacity = initialCapacity;
int* ptr = cast(int*)alloca(capacity * T.sizeof);
ptr += initialCapacity - 1; // correct?

foreach_reverse (i; 0 .. n) {
if (i = capacity) {
alloca(capacity * T.sizeof);
capacity *= 2;
}
ptr--;
*ptr = i;
len++;
}

writeln(len, capacity: , len,  , capacity);
auto arr = ptr[0 .. len];
writeln(arr);
}


Beware of stack overflows.

Bye,
bearophile


Re: Question about typeof(this)

2010-09-07 Thread Don

Jacob Carlborg wrote:

On 2010-09-07 17:29, Don wrote:

Jacob Carlborg wrote:

I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof
where it says:

typeof(this) will generate the type of what this would be in a
non-static member function, even if not in a member function. 

From that I got the impression that the code below would print the
same result, but it doesn't. It prints:

main.Bar
main.Foo

instead of:

main.Foo
main.Foo

Is this a bug or have I misunderstood the docs?


typeof(this) gives the *compile-time* type of this. Inside Bar, it has
to return 'Bar'.
typeid(this) gives the *runtime* type of this. So it can work that it's
Bar is actually a Foo.


I know that typeof(this) is a compile time expression but in this case I 
think the compiler has all the necessary information at compile time. 
Note that I'm not calling method on a base class reference, I'm 
calling it on the static type Foo. In this case I think typeof(this) 
would resolve to the type of the receiver, i.e. the type offoo.


Even though in this instance it could work out which derived class is 
being used, it's not allowed to use that information while compiling 
method(). There is only ONE function method(), and it has to work for 
Bar, and all classes derived from Bar.


Re: Input Scanning

2010-09-07 Thread Jonathan M Davis
On Tuesday 07 September 2010 09:55:29 Max Mayrhofer wrote:
 Hi all, I have what is I suspect a silly question, but I am having a
 total brainfart over this for some reason.  I want to read an
 arbitrary amount of floats from user input and then perform some
 statistics work on them. For some reason, I can't figure out how to
 get it to recognise when the user has stopped entering values.  My
 current code is:
 
 void main(string[] args) {
   Stat[] stats;
   foreach (arg; args[1 .. $]) {
   auto newStat = cast(Stat) Object.factory(main. ~
 arg);
   enforce(newStat, Invalid statistics function:  ~
 arg);
   stats ~= newStat;
   }
   for (double x; stdin.readf( %s , x) == 1; ) {
   foreach (s; stats) {
   s.accumulate(x);
   }
   }
   foreach (s; stats) {
   s.postprocess();
   writeln(s.result());
   }
 }
 
 At the moment it just crashes with a conversion error when invoked,
 for example, with:
 
 echo 3 1.6 17 | stats Min Average
 
 I know my problem is the readf, but what would best practice be for
 this situation?

Wouldn't the normal solution be to read in the entire line and then parse it 
rather than reaing in each value individually? So, wouldn't you use 
std.stdio.readln() to read the line from stdin and std.conv.parse() to parse 
out 
the values?

- Jonathan M Davis


Re: How to link in a lib on cmd line?

2010-09-07 Thread Nick Sabalausky
Nick Sabalausky a...@a.a wrote in message 
news:i66oia$25s...@digitalmars.com...
 I've tried all sorts of stuff and looked all over, but I'm completely at a 
 loss. How do I link in a static lib on the command line?

And I don't mean with C or anything like that, just ordinary D.

 type main.d
module main;
import theLib;
void main()
{
foo();
}

 type theLib.d
module foo;
import std.stdio;
void foo()
{
writeln(In foo);
}

 dmd theLib.d -lib

 dmd main.d -LtheLib.lib
OPTLINK (R) for Win32  Release 8.00.2
Copyright (C) Digital Mars 1989-2009  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 9: Unknown Option : NOITHELIB.LIB
main.obj(main)
 Error 42: Symbol Undefined _D3foo12__ModuleInfoZ
main.obj(main)
 Error 42: Symbol Undefined _D3foo3fooFZv
--- errorlevel 2

Same results for -LtheLib.
I saw something about -L-ltheLibNameHere somewhere, but -L-ltheLib.lib 
gets me:

OPTLINK (R) for Win32  Release 8.00.2
Copyright (C) Digital Mars 1989-2009  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 9: Unknown Option : LTHELIB.LIB
main.obj(main)
 Error 42: Symbol Undefined _D3foo12__ModuleInfoZ
main.obj(main)
 Error 42: Symbol Undefined _D3foo3fooFZv
--- errorlevel 2

And with -L-ltheLib the message just says LTHELIB instead of 
LTHELIB.LIB





Re: How to link in a lib on cmd line?

2010-09-07 Thread Jonathan M Davis
On Tuesday 07 September 2010 18:23:59 Nick Sabalausky wrote:
 I've tried all sorts of stuff and looked all over, but I'm completely at a
 loss. How do I link in a static lib on the command line?

Don't you just include it as one of the arguments, like all of the .d files? I 
don't know. I haven't had a need to link in static libs before, and I usually 
do 
the linking step myself with gcc so that I can get a static binary (since -L-
static doesn't currently work with dmd).

- Jonathan M Davis


An array()/map inlining problem

2010-09-07 Thread bearophile
This is interesting, if you compile it with:
dmd test.d
It works. If you compile it with:
dmd -inline test.d
It doesn't compile and dmd returns:
test.d(5): Error: function D main is a nested function and cannot be accessed 
from array


import std.algorithm: map;
import std.array: array;
void main() {
int c;
array(map!((x){return c;})([1]));
}


I think this is a compiler bug, right (because I think it must not compile in 
both cases or compile in both)?

Bye,
bearophile


Re: Input Scanning

2010-09-07 Thread Max Mayrhofer
Yea of course that does make sense, there ya go :)


[Issue 4826] cannot create associative array and compiler crash

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4826


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

   Keywords||diagnostic


--- Comment #3 from Don clugd...@yahoo.com.au 2010-09-06 23:56:32 PDT ---
Reduced test case:
--
struct Struct4826 {}

void bug4826(T)(T[string] value) {}

void test4826()
{
bug4826(Struct4826());
}


This is closely related to bug 3996. The patch for bug 3996 removes the
segfault, leaving only a useless error message with no line number, followed by
a sensible error message with line number.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4826] cannot create associative array and compiler crash

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4826



--- Comment #4 from Don clugd...@yahoo.com.au 2010-09-07 00:04:26 PDT ---
Actually even with the patch for bug 3996, I found a test case which still
segfaults:

struct Struct4826 { }

void bug4826b(T)(int[int] value) {}

void test4826b()
{
bug4826b(Struct4826());
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4835] New: DMD should warn about integer overflow in computed constant

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4835

   Summary: DMD should warn about integer overflow in computed
constant
   Product: D
   Version: D2
  Platform: x86_64
OS/Version: Linux
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: lars.holo...@gmail.com


--- Comment #0 from Lars Holowko lars.holo...@gmail.com 2010-09-07 10:09:23 
PDT ---
I got bitten by this when I wanted to create a 6GB large file to test 64 bit
support in std.stdio with dmd 2.048.


The output of:


import std.stdio;

void main(string args[])
{
long l_dangerous = 1024 * 1024 * 1024 * 6;
writefln(l_dangerous = 0x%x, l_dangerous);
writefln(l_dangerous = %s, l_dangerous);

long l_ok = 1024 * 1024 * 1024 * 6L;
writefln(l_ok = 0x%x, l_ok);
writefln(l_ok = %s, l_ok);
return;
}

is

l_dangerous = 0x8000
l_dangerous = -2147483648
l_ok = 0x18000
l_ok = 6442450944


dmd 2.048 did not issue a warning about the integer overflow (neither with or
without -w)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4835] DMD should warn about integer overflow in computed constant

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4835


bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #1 from bearophile_h...@eml.cc 2010-09-07 12:39:13 PDT ---
I'm asking for overflow detection for years (both at compile-time and
run-time).

Again here the C language is better than the D language:

// C code
#include stdio.h
int main() {
long long x = 1024 * 1024 * 1024 * 6;
printf(%lld\n, x);
return 0;
}


GCC 4.3.4 gives:
prog.c: In function ‘main’:
prog.c:3: warning: integer overflow in expression

D compiler is not _practical_ enough yet.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4836] New: duplicated union initialization without a union

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4836

   Summary: duplicated union initialization without a union
   Product: D
   Version: D2
  Platform: x86_64
OS/Version: Linux
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: i.kas...@gmx.de


--- Comment #0 from Ivo Kasiuk i.kas...@gmx.de 2010-09-07 12:49:28 PDT ---
The following compilation error does not seem to make sense:

$ cat test.d
class C {
  string s = null;
  mixin template M() { }
  mixin M!() m1;// line 4
  mixin template M(T) { }   // line 5
  mixin M!(int) m2;
}
$ dmd -c test
test.d(1): Error: class test.C duplicated union initialization for s
$

Interestingly, the file compiles without error if line 4 and 5 are swapped.

Tested with DMD v2.048

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4837] New: Assertion failure: '0' on line 608(614) in file 'constfold.c' during CTFE

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4837

   Summary: Assertion failure: '0' on line 608(614) in file
'constfold.c' during CTFE
   Product: D
   Version: D2
  Platform: x86_64
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: stanislav.bli...@gmail.com


--- Comment #0 from Stanislav Blinov stanislav.bli...@gmail.com 2010-09-07 
13:05:21 PDT ---
Compilation fails with assertion in constfold.c:608 or constfold.c:614 for the
following code:

bool foo(T)(T t)
{
t = 1;   // triggers assertion for ubytes and ushorts
// t = t  1; // this compiles with no errors
return true;
}

void main()
{
auto g1 = foo!ubyte(1); // Ok for runtime
auto g2 = foo!ushort(1); // Ok for runtime

// CTFE:
enum e1 = foo!ubyte(1);  // Assertion failure: '0' on line 608 in file
'constfold.c'
enum e2 = foo!ushort(1); // Assertion failure: '0' on line 614 in file
'constfold.c'
}

DMD 2.048

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4826] cannot create associative array and compiler crash

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4826



--- Comment #5 from Don clugd...@yahoo.com.au 2010-09-07 13:47:50 PDT ---
The segfault should be turned into an ICE by adding an extra assert into
TypeAArray::getImpl(), in mtype.c 3967.

+assert(ti-inst || sc);
ti-semantic(sc);
ti-semantic2(sc);
ti-semantic3(sc);

The problem is, that the template instance needs a scope (sc), but the scope is
never set, so it remains NULL, causing a segfault when it is first used. I
don't know how to solve this. I'm not even sure of what the scope should be.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4838] New: Cannot declare a delegate variable for const member functions

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4838

   Summary: Cannot declare a delegate variable for const member
functions
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: major
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: c...@klickverbot.at


--- Comment #0 from klickverbot c...@klickverbot.at 2010-09-07 15:38:30 PDT 
---
Given �class A { void foo() const {} }; A a = new A;�,
�typeof(a.foo).stringof� yields �void delegate() const�.

However, trying to declare a delegate variable of this type like �void
delegate() const dg; dg = a.foo;� fails with �const/immutable/shared/inout
attributes are only valid for non-static member functions� or, depending on the
scope one tries to declare the variable in, even more cryptic error messages.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4834] Implicit sharing via delegates in std.concurrency

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4834


David Simcha dsim...@yahoo.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #1 from David Simcha dsim...@yahoo.com 2010-09-07 16:07:02 PDT ---
http://dsource.org/projects/phobos/changeset/1964

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4814] rdmd: Doesn't rebuild when using -of and turning an -L linker option on or off

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4814


Nick Sabalausky cbkbbej...@mailinator.com changed:

   What|Removed |Added

Summary|rdmd: Doesn't rebuild when  |rdmd: Doesn't rebuild when
   |using -of and turning   |using -of and turning an -L
   |-L--export-dynamic on or|linker option on or off
   |off |


--- Comment #1 from Nick Sabalausky cbkbbej...@mailinator.com 2010-09-07 
16:16:16 PDT ---
This seems to apply to any linker option.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4838] Cannot declare a delegate variable for const member functions

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4838


bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #1 from bearophile_h...@eml.cc 2010-09-07 16:33:20 PDT ---
Maybe you want to rewrite those code snippets into readable indented little
runnable programs.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3564] Rdmd failing to link external C libraries

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3564


Nick Sabalausky cbkbbej...@mailinator.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||INVALID


--- Comment #2 from Nick Sabalausky cbkbbej...@mailinator.com 2010-09-07 
19:01:56 PDT ---
There's one more file I forgot to include in my example above:


$ cat theLib.di
module theLib;
void foo();


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3564] Rdmd failing to link external C libraries

2010-09-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3564


Nick Sabalausky cbkbbej...@mailinator.com changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|INVALID |


--- Comment #3 from Nick Sabalausky cbkbbej...@mailinator.com 2010-09-07 
19:19:08 PDT ---
Reopening, didn't notice this was regarding linking to C.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---