Is it possible to assumeSafeAppend malloced memory?

2014-05-18 Thread Ali Çehreli via Digitalmars-d-learn
We know that most of the time memory is allocated more than the requested amount. Is there a way to take advantage of that extra trailing space? (And potentially the pages that come after that.) import core.memory; void main() { const count = 1; // I think there is extra capacity beyo

Re: Modify char in string

2014-05-18 Thread Chris Cain via Digitalmars-d-learn
On Sunday, 18 May 2014 at 18:55:59 UTC, Tim wrote: Hi everyone, is there any chance to modify a char in a string like: As you've seen, you cannot modify immutables (string is an immutable(char)[]). If you actually do want the string to be modifiable, you should define it as char[] instead.

Re: Modify char in string

2014-05-18 Thread bearophile via Digitalmars-d-learn
Tim: is there any chance to modify a char in a string like: void main() { string sMyText = "Replace the last char_"; sMyText[$ - 1] = '.'; } But when I execute the code above I'm always getting "cannot modify immutable expression at sMyText[__dollar -1LU]". I though D supported such mo

Modify char in string

2014-05-18 Thread Tim via Digitalmars-d-learn
Hi everyone, is there any chance to modify a char in a string like: void main() { string sMyText = "Replace the last char_"; sMyText[$ - 1] = '.'; } But when I execute the code above I'm always getting "cannot modify immutable expression at sMyText[__dollar -1LU]". I though D supported

Re: Video playback

2014-05-18 Thread Dmitry via Digitalmars-d-learn
On Sunday, 18 May 2014 at 07:37:33 UTC, Rikki Cattermole wrote: My suggestion would be to go the direction of libvlc[0]. I did find a forum post from SFML that may help you. It is a c library so it shouldn't be too hard to create a binding to. Perhaps something along the lines of Derelict-Util[

Re: Problems with dmd Switches in Makefiles

2014-05-18 Thread via Digitalmars-d-learn
For the compiler version, I've submitted a PR: https://github.com/D-Programming-Language/dmd/pull/3558

Re: UCFS does not work for nested functions?

2014-05-18 Thread bearophile via Digitalmars-d-learn
Steffen Wenz: Just noticed that using UFCS does not work for nested functions, Right. and was wondering whether that's intended, and what the rationale behind it is: Currently it's intended. Because doing otherwise causes other problems with struct/class member functions. Perhaps there a

UCFS does not work for nested functions?

2014-05-18 Thread Steffen Wenz via Digitalmars-d-learn
Hi, Just noticed that using UFCS does not work for nested functions, and was wondering whether that's intended, and what the rationale behind it is: class X { void foo() {} } void main() { // moving bar to module scope solves the error below void bar(X x) {}

Re: Video playback

2014-05-18 Thread Rikki Cattermole via Digitalmars-d-learn
On 18/05/2014 7:10 p.m., Dmitry wrote: Hi everyone! I want to play video in my D-application (maybe WebM or Theora). However didn't find any library for operation with video in D. I am a beginner in D, experience of transfer of libraries with C/C++, certainly isn't present. Maybe somebody will pr

Re: randomSample

2014-05-18 Thread bearophile via Digitalmars-d-learn
Meta: You need to use the function array from std.array. import std.array; int[] source = [ ... ]; int[] sample = randomSample(source, 3).array(); In some cases it's also useful to use std.algorithm.copy: void main() { import std.stdio, std.algorithm, std.random, std.array,

Video playback

2014-05-18 Thread Dmitry via Digitalmars-d-learn
Hi everyone! I want to play video in my D-application (maybe WebM or Theora). However didn't find any library for operation with video in D. I am a beginner in D, experience of transfer of libraries with C/C++, certainly isn't present. Maybe somebody will prompt something? P.S. My application