__ctfe can be used for this purpose:
"The __ctfe boolean pseudo-variable, which evaluates to true at
compile time, but false at run time, can be used to provide an
alternative execution path to avoid operations which are
forbidden at compile time. Every usage of __ctfe is evaluated
before cod
Vlad Levenfeld:
Is there any way that I can detect whether or not a function is
being evaluated at compile time? Specifically I want to switch
between to use/not to use memoize!func without having to figure
out when its CTFE-able and calling it with different syntax.
Calling it with a differ
Is there any way that I can detect whether or not a function is
being evaluated at compile time? Specifically I want to switch
between to use/not to use memoize!func without having to figure
out when its CTFE-able and calling it with different syntax.
On Saturday, 31 May 2014 at 22:54:48 UTC, Qox wrote:
scope(exit) foo();
uses exception handling in the background.
That just works with dmd even in the bare metal environmnet.
Throwing an exception needs library support with dmd but you can
copy/paste it from druntime - I did that in my min
"Jonathan M Davis via Digitalmars-d-learn" wrote in message
news:mailman.1421.1401576730.2907.digitalmars-d-le...@puremagic.com...
> By dynamic linking do you mean LoadLibrary or linking with import
> library?
Both will work, otherwise we couldn't use Microsoft's libraries - e.g.
std.windows.
On Saturday, 31 May 2014 at 22:34:45 UTC, Timon Gehr wrote:
On 06/01/2014 12:25 AM, Ali Çehreli wrote:
dec10 little = cast(dec10(bingo));
You meant cast(dec10)(bingo).
assert(little == dec10("123.45"));
Is this expected behavior?
Paul
That is surprising. I've discovered that if the tem
On Saturday, 31 May 2014 at 07:57:18 UTC, Kagamin wrote:
http://www.xomb.org/ ?
seems to be outdated, but its another OS written in D.
You should definitly use templating and CTFE for your advantage.
For example you could use the (compile time) component based
design to design (heap) allocators after a at cmpile time known
configuration. The possibilities of templating and compile time
code gen are enormous.
Instead of using
On Sat, 31 May 2014 07:53:40 +
Kagamin via Digitalmars-d-learn
wrote:
> By dynamic linking do you mean LoadLibrary or linking with import
> library?
Both will work, otherwise we couldn't use Microsoft's libraries - e.g.
std.windows.registry uses advapi32.dll to talk to the registry. But stat
Chris Nicholson-Sauls:
Good... I was starting to fear I was the only one.
In general you can't fix the names in a language because you
always find someone that likes the ones present :) I think "enum"
is a bad name for the purpose of defining manifest constants, but
I don't think this will
On Saturday, 31 May 2014 at 22:13:35 UTC, monarch_dodra wrote:
On Saturday, 31 May 2014 at 21:21:59 UTC, Paul D Anderson wrote:
'enum' as a manifest constant keyword has been an unpopular
decision from its introduction. "Everybody" agrees that it
should be changed. Everybody but Walter
I find
On 06/01/2014 12:25 AM, Ali Çehreli wrote:
dec10 little = cast(dec10(bingo));
You meant cast(dec10)(bingo).
assert(little == dec10("123.45"));
Is this expected behavior?
Paul
That is surprising. I've discovered that if the template has members
that depend on a template parameter than th
On 05/31/2014 02:11 PM, Paul D Anderson wrote:
I'm working on the decimal number package for D. A decimal is a struct
with precision, max exponent and rounding mode parameters:
"Decimal!(PRECISION, MAX_EXPO, ROUNDING)". I was trying to overload the
opCast operator for this struct and I found that
On Saturday, 31 May 2014 at 21:21:59 UTC, Paul D Anderson wrote:
'enum' as a manifest constant keyword has been an unpopular
decision from its introduction. "Everybody" agrees that it
should be changed. Everybody but Walter
I find enum makes sense.
On 31/05/14 23:22, Joseph Rushton Wakeling via Digitalmars-d-learn wrote:
It's due to the the updated uniform() provided in this pull request:
https://github.com/D-Programming-Language/phobos/commit/fc48d56284f19bf171780554b63b4ae83808b894
You can see the effects in action by running e.g. the f
On 05/31/2014 11:21 PM, Paul D Anderson wrote:
On Saturday, 31 May 2014 at 20:14:59 UTC, bearophile wrote:
Miles Stoudenmire:
In contrast to those two examples where immutable can be used at compile
time, what are some other cases where it is necessary to use enum
instead of immutable?
By de
Paul D Anderson:
'enum' as a manifest constant keyword has been an unpopular
decision from its introduction.
I agree, I too asked for a better name.
Bye,
bearophile
On Saturday, 31 May 2014 at 20:14:59 UTC, bearophile wrote:
Miles Stoudenmire:
In contrast to those two examples where immutable can be used
at compile
time, what are some other cases where it is necessary to use
enum instead of immutable?
By default use enum if you define a compile-time-kno
On 31/05/14 22:37, Joseph Rushton Wakeling via Digitalmars-d-learn wrote:
On 30/05/14 22:45, monarch_dodra via Digitalmars-d-learn wrote:
Didn't you make changes to how and when the global PRNG is popped and accessed
in randomShuffle? I figured it *could* be an explanation.
I think it's more l
I'm working on the decimal number package for D. A decimal is a
struct with precision, max exponent and rounding mode parameters:
"Decimal!(PRECISION, MAX_EXPO, ROUNDING)". I was trying to
overload the opCast operator for this struct and I found that it
does not seem necessary. I can cast decim
On 30/05/14 22:45, monarch_dodra via Digitalmars-d-learn wrote:
Didn't you make changes to how and when the global PRNG is popped and accessed
in randomShuffle? I figured it *could* be an explanation.
No, it was partialShuffle that I tweaked, and that shouldn't affect the results
here. There
Miles Stoudenmire:
In contrast to those two examples where immutable can be used
at compile
time, what are some other cases where it is necessary to use
enum instead of immutable?
By default use enum if you define a compile-time-known value,
unless it's composed data like an array, etc.
By
In contrast to those two examples where immutable can be used at compile
time, what are some other cases where it is necessary to use enum instead
of immutable?
On 31 May 2014 09:33, Andrej Mitrovic via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:
> This has been asked so many
On Saturday, 31 May 2014 at 16:34:00 UTC, Joseph Rushton Wakeling
via Digitalmars-d-learn wrote:
Hello all,
Is there a straightforward way to indicate that two modules
should not be used together in the same program? Preferably
one that does not require editing both of the modules?
The appl
See: http://dlang.org/function.html#variadicnested
The second example explains that nested functions can be accessed only
if the name is in scope.
Looking at old data, it is the dmd version that's changed, so I
think this is the likely reason.
Andrew
On Friday, 30 May 2014 at 20:45:23 UTC, monarch_dodra wrote:
On Friday, 30 May 2014 at 18:41:55 UTC, Joseph Rushton Wakeling
via Digitalmars-d-learn wrote:
On 30/05/14 18:13, monarch_dodra
On Sat, May 31, 2014 at 04:50:11PM +, matovitch via Digitalmars-d-learn
wrote:
> Hi !
>
> Does anybody knows why dmd segfaults on this code ? Should I report
> this as a bug ?
[...]
Compiler segfaults should always be reported. No matter how wrong the
code may be, it is never right for the c
I updated the issue. Strangely if done in the main everything is
fine :
Error: undefined identifier i
On Saturday, 31 May 2014 at 17:22:41 UTC, matovitch wrote:
In fact it segfauls on any template parameter if it has the
same name as the immutable member (at least it's coherent).
Something as simple as :
struct Foo(int i)
{
immutable int i = i;
}
void main()
{
Foo!5 foo;
writeln(f
I remembered my psswd don't take my last sentence into account (i
will filed this).
In fact it segfauls on any template parameter if it has the same
name as the immutable member (at least it's coherent). Something
as simple as :
struct Foo(int i)
{
immutable int i = i;
}
void main()
{
Foo!5 foo;
writeln(foo);
}
I am suprised that nobody tried this before. BTW I a
On Saturday, 31 May 2014 at 17:01:23 UTC, bearophile wrote:
matovitch:
Does anybody knows why dmd segfaults on this code ? Should I
report this as a bug ?
Please report this minimized case to Bugzilla:
struct Foo(int[] arr) {
const int[] arr = arr;
}
void main() {
Foo!([0]) foo;
}
matovitch:
Does anybody knows why dmd segfaults on this code ? Should I
report this as a bug ?
Please report this minimized case to Bugzilla:
struct Foo(int[] arr) {
const int[] arr = arr;
}
void main() {
Foo!([0]) foo;
}
The error it gives before the crash:
test.d(2,17): Deprecat
Hi !
Does anybody knows why dmd segfaults on this code ? Should I
report this as a bug ?
import std.stdio;
enum LiftingGender
{
PREDICT,
UPDATE,
}
struct Test(float[][] coeffs,
int[] offsets,
LiftingGender gender)
{
immutable float[][] coeffs = coeffs;
Hello all,
Is there a straightforward way to indicate that two modules should not be used
together in the same program? Preferably one that does not require editing both
of the modules?
The application I have in mind is when one is making available an experimental
module which is planned to
On Saturday, 31 May 2014 at 16:18:35 UTC, DLearner wrote:
Is this intended?
Yes, nested functions access local variables and thus follow the
same order of declaration rules as they do; you can't use a local
variable before it is declared so same with a nested function.
Hi,
import std.stdio;
void main() {
writefln("Entered");
sub1();
sub1();
sub1();
writefln("Returning");
void sub1() {
static int i2 = 6;
i2 = i2 + 1;
writefln("%s",i2);
};
}
does not compile, but
import std.stdio;
void main() {
void sub1() {
This has been asked so many times, is this info not on the website? We
should have an article on the site explaining this in depth. OT: Sorry for
top-quoting and over-quoting.
On Friday, May 30, 2014, monarch_dodra via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:
> On Friday, 30
On Saturday, 31 May 2014 at 07:28:32 UTC, Mineko wrote:
So, I've gotten interested in kernel programming in D.. And as
much as I like C/C++, I wanna try innovating, I'm aware that
phobos/gc and any OS-specific issues are going to be a problem,
but I'm willing to implement them into the kernel i
On Saturday, 31 May 2014 at 07:28:32 UTC, Mineko wrote:
Any ideas? :P
Buy my book, chapter 11 talks about it a little to get you
started :P
http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book
The summary of my approach there is:
1) Use a regular linux compiler an
http://www.xomb.org/ ?
>> What do you mean? Like this?
>>
>> Hidden* foo() { return new Hidden();}
>
> Yes, this way you can control all aspects of the construction and use. You
> wouldn't need to make it private even, just don't lay out the struct in the
> normal import:
>
> struct Hidden;
>
> I think you would need to
By dynamic linking do you mean LoadLibrary or linking with import
library?
On Sat, May 31, 2014 at 6:39 AM, Dicebot via Digitalmars-d-learn
wrote:
> private in D does not provide any strong guarantees, it only controls direct
> access to the symbol. You effectively want some sort of strict internal
> linkage attribute which does not exist in D.
Indeed. I will learn to u
On Sat, 31 May 2014 06:38:46 +
Kagamin via Digitalmars-d-learn
wrote:
> They may use different debugging formats, but just linking should
> be possible, especially with import libraries.
_Dynamic_ linking is possible. Static linking is not.
- Jonathan M Davis
So, I've gotten interested in kernel programming in D.. And as
much as I like C/C++, I wanna try innovating, I'm aware that
phobos/gc and any OS-specific issues are going to be a problem,
but I'm willing to implement them into the kernel itself.
So, I guess what I'm asking is this: What should
On Saturday, 31 May 2014 at 06:54:13 UTC, Russel Winder via
Digitalmars-d-learn wrote:
On Fri, 2014-05-30 at 16:44 +, Andrew Brown via
Digitalmars-d-learn
wrote:
GDC version 4.8.2,i guess that's my problem. This is what
happens
when you let Ubuntu look after your packages.
Debian Sid has
47 matches
Mail list logo