On Tue, Nov 25, 2014 at 4:12 PM, "Nordlöw"
wrote:
> Is there a way to (on the fly) reduce Pegged parse results such as
>
> C [0, 6]["int", "x", ";"]
> +-C.TranslationUnit [0, 6]["int", "x", ";"]
> +-C.ExternalDeclaration [0, 6]["int", "x", ";"]
>+-C.Declaration [0, 6]["int", "x", ";"]
On Mon, Nov 3, 2014 at 3:27 PM, Dominikus Dittes Scherkl via
Digitalmars-d-learn wrote:
> If I have a struct with numeric template parameter, how can I access it
> within member functions? Like normal member variables? And how about the
> constructor?
>
> struct polynomial(uint base)
> {
> private
Any time you want to return or store a group of values of different types.
In a way, tuples are just structs without a name (anonymous structs,
if you will).
Say you have function `foo' and want it to return an int and a string.
In D, you cannot do:
(int, string) foo() { ... return (3, "abc");}
> I thought you were expanding it
Drat. *You* thought you were expanding it.
On Sat, Nov 1, 2014 at 9:34 PM, Suliman via Digitalmars-d-learn
wrote:
> Few questions.
>
> 1. In examples tuples are created with keyword auto. Can I create them with
> another keyword. Or auto mean structure of data, that have not standard type
> like (int or string)?
`tuple' is a function defi
You can also create new types:
struct UseSprite { string s;}
struct UseAnimation { string s;}
>> It's not a class instance, it's a class type. Something like
>> `cast(Sprite) null` in parameters. It can be replaced by string
>> "Sprite", but in this case I can't use receive() as it is. E.g.
>>
>
> Ah that sounds interesting too! Immediately I start thinking in terms like
> tidlywiki http://tiddlywiki.com/ or something similar, I guess the emacs way
> described earlier also would support this. I personally always enjoy reading
> the readthedocs stuff http://docs.readthedocs.org/en/latest/ i
> I recommend slightly more generic form:
>
> template Alias(T...)
> if (T.length == 1)
> {
> alias Alias = T[0];
> }
>
> it is quite helpful in templated code to be able to alias _anything_
That's what I use also, but didn't want another thread on the (T...)
if (T.length ==1) trick :)
>
> It is basically just an annoying grammar limitation that does not allow to
> use mixin / __traits as an identifier.
The usual helper template:
```
alias helper(alias a) = a;
```
helps for aliasing __traits and anonymous function templates (x =>
x+1), but I don't see an easy solution for mi
> dmd -c -o- macros.ddoc doc.ddoc -Df{ddoc_filename}.html {ddoc_filename}.dd
>
> If someone knows of a more "official" syntax, please let me know.
I don't know of another syntax, but could you please put this
somewhere on the wiki?
Maybe in the cookbook section:
http://wiki.dlang.org/Cookbook
> instead I would like to use "EAT_FOOD_DECISION" and "EAT_FOOD_BEHAVIOUR" and
> get the functions?
>
> Is that possible somehow?
If all your functions had the same signature, you could use an
associative array FunctionType[string] and initialize it:
FunctionType[string] myFuncs;
myFuncs["EAT_FO
On Friday, 29 August 2014 at 23:58:19 UTC, Chris Cain wrote:
I used https://www.npmjs.org/package/literate-programming (+
pandoc) to do this when writing
https://dl.dropboxusercontent.com/u/2206555/uniformUpgrade.pdf
in markdown.
Do you remember if some snippets can be hidden in the final
do
On Sat, Aug 30, 2014 at 1:37 AM, nikki wrote:
I wasn't too happy about it and I wrote my own little parse
thingie and have
a literate version nice and meta and small and sloppy ;)
http://nikkikoole.github.io/docs/dokidokDOC.html
I use it to change my d sourcefile slightly (into valid
markdown
>> gdc just compiles the program to a.out. It doesn't run the
>> resulting executable. You need to use something like rdmd instead
>> of gdc. rdmd compiles to some temporary location and then runs
>> the executable.
>
>
> Wow, that was fast. Thanks a lot!
Can compiler switches be used with the she
On Wed, Aug 20, 2014 at 5:34 PM, Dominikus Dittes Scherkl via
Digitalmars-d-learn wrote:
> On Wednesday, 20 August 2014 at 15:26:14 UTC, monarch_dodra wrote:
>>
>> AFAIK, it's a historical workaround to accept T as either alias or not
>> alias, as varargs have "auto alias". EG:
>>
>> foo!int //OK
>> A foreach becomes compile-time whenever the aggregate is a purely compile-
>> time construct such as a tuple.
Yeah, I think you transformed it into a runtime array by using [ ...
]. Tuples with compatible types can be 'downgraded' to arrays that
way. But there is no need to: tuples are iterable
Artur:
> @safe, @trusted, @system, shared, immutable, const, inout and `extern (...)`
> affect child scopes. `synchronized` does too, but in a rather unintuitive
> way; hopefully nobody uses this. ;)
Well, I also hope no one uses inout: at the module level?
> Other attributes, including 'pure' an
On Sat, Aug 16, 2014 at 1:30 PM, Artur Skawina via Digitalmars-d-learn
wrote:
> On 08/16/14 13:18, Philippe Sigaud via Digitalmars-d-learn wrote:
>> We indeed need to put annotations inside aggregates to
>> affect their innards.
>>
>> If that's true, I have a lo
>>> If I understand correctly Adam Ruppe's Cookbook, by putting
>>>
>>> @safe:
>>> pure:
>>> nothrow:
>>>
>>> at the beginning of a module, I distribute it on all definitions, right?
>>> Even methods, inner classes, and so on?
I read Adam's book again and I was wrong:
Chapter 7, p. 173:
"You may
On Fri, Aug 15, 2014 at 10:04 PM, John Colvin via Digitalmars-d-learn
wrote:
> compiler, version, OS, architecture, flags?
Compiler: DMD 2.065 and LDC 0.14
OS: Linux 64bits (8 cores, but there is no parallelism here)
flags: -O -release -inline (and -noboundscheck for DMD)
> Have you looked at
In another module I marked as '@safe:' at the top, the compiler told
me that a class opEquals could not be @safe (because Object.opEquals
is @system).
So it seems that indeed a module-level '@safe:' affects everything,
since a class method was found lacking.
(I put a @trusted attribute on it).
On Friday, 15 August 2014 at 16:48:10 UTC, monarch_dodra wrote:
On Friday, 15 August 2014 at 14:40:36 UTC, Philippe Sigaud
wrote:
Well, I created a wrapper around a
std.array.uninitializedArray call, to manage the interface I
need
Make sure you don't use that if your type has elab
So I'm trying to use @safe, pure and nothrow.
If I understand correctly Adam Ruppe's Cookbook, by putting
@safe:
pure:
nothrow:
at the beginning of a module, I distribute it on all definitions,
right? Even methods, inner classes, and so on?
Because I did just that on half a dozen of modules
Well, I created a wrapper around a std.array.uninitializedArray
call, to manage the interface I need (queue behavior: pushing at
the end, popping at the beginning). When hitting the end of the
current array, it either reuse the current buffer or create a new
one, depending of the remaining capa
On Fri, Aug 15, 2014 at 1:57 PM, Messenger via Digitalmars-d-learn
wrote:
> T[size] beats all of those on dmd head, though it is inarguably a
> bit limiting.
I confirm (even with 2.065). With ldc2 it's optimized out of the way,
so it gives 0 hnsecs :-)
Hmm, what about a sort of linked list of st
> It is very different with better compiler though :
>
> $ ldmd2 -release -O a.d
> $ ./appendertest
> Appender.put :378 ms, 794 μs, and 9 hnsecs
> Appender ~=:378 ms, 416 μs, and 3 hnsecs
> Std array :2 secs, 222 ms, 256 μs, and 2 hnsecs
> Std array.reserve :2 secs, 199 ms,
On Thu, Aug 14, 2014 at 11:33 PM, Joseph Rushton Wakeling via
Digitalmars-d-learn wrote:
> On 14/08/14 19:16, Philippe Sigaud via Digitalmars-d-learn wrote:
>>
>> Do people here get good results from Appender? And if yes, how are you
>> using it?
>
>
> An example
> I wonder if using plain `Array` instead may be result in better performance
> where immutability is not needed.
Hmm, no:
module appendertest;
import std.array;
import std.datetime;
import std.stdio;
import std.container;
enum size = 1_000;
void test1()
{
auto arr = appender!(int[])();
> Quick test...
Ah, thanks a lot Jonathan. I kept telling me I should probably test it
on a simple case.
OK, the good news is, Appender works in these cases (I mean, that's
good news for Phobos).
Now, I just have to find out why it's slower in my case :)
>
> import std.array;
>
> Thanks! Repeating what I have mentioned during DConf talk - have you ever
> considered proposing Pegged for Phobos inclusion? It feels like important
> bit of infrastructure to me.
At the time, it was considered (rightfully) far too slow and
memory-hogging. I think having a generic lexer and a s
>> There is a misunderstanding there: I'm using clear only to flush the
>> state at the beginning of the computation. The Appender is a class
>> field, used by the class methods to calculate. If I do not clear it at
>> the beginning of the methods, I keep appending new results to old
>> computation
> I've never really tried to benchmark it, but it was my understanding that
> the idea behind Appender was to use it to create the array when you do that
> via a lot of appending, and then you use it as a normal array and stop using
> Appender.
That's how I use it, yes.
> It sounds like you're tr
> I don't know much about Phobos appender implementation details but the key
> thing with reusable buffer is avoid freeing them. AFAIR Appender.clear frees
> the allocated memory but `Appender.length = 0` does not, making it possible
> to just overwrite stuff again and again.
I call .clear() only
From time to time, I try to speed up some array-heavy code by
using std.array.Appender, reserving some capacity and so on.
It never works. Never. It gives me executables that are maybe
30-50% slower than bog-standard array code.
I don't do anything fancy: I just replace the types, use clear()
On Mon, Aug 11, 2014 at 10:58 PM, H. S. Teoh via Digitalmars-d-learn
wrote:
> In Flex, one way you can implement heredocs is to have a separate "mode"
> where the lexer is scanning for the ending string. So basically you
> have a sub-lexer that treats the heredoc as three tokens, one that
> defi
On Mon, Aug 11, 2014 at 10:09 PM, H. S. Teoh via Digitalmars-d-learn
wrote:
> On Mon, Aug 11, 2014 at 07:47:44PM +, Klaus via Digitalmars-d-learn wrote:
>> I mean when writing a D lexer, you necessarly reach the moment when
>> you think:
>>
>> "Oh no! is this feature just here to suck ?"
> T
> hmmm static and private... other keywords to
> try, but offhand it's been a while i don't know if either would change the
> behavior. Could just be inner scope limitations. Might be other
> tags/modifiers...
>
> I feel helpless :(
No need to ;-) Thanks for your help, don't sweat it too much.
>
On Wed, Aug 6, 2014 at 9:09 AM, Uranuz via Digitalmars-d-learn
wrote:
> What I was thinking about is possibility to change ParseTree struct with
> user-defined version of it. And I was thinking about setting tree type as
> template parameter to grammar:
>
> grammar!(MyParseTree)("
> Arithmetic:
>
> Yea, but that won't work for forward ranges. It only provides opIndex if the
> underlying range provides it. Since the chunk size is a runtime parameter it
> can't implement opIndex efficiently for non-random access ranges.
But in your case, your range is random-access, no?
Or else, you can alw
Era:
broken_b.foo(); //i_a is accessible invisibly because
overridden or transformed assuming it would be converted or
copied/moved as appropriate.
return b; //if a is a local variable then b becomes invalid
even though it's a struct.
return i_b; //same as return b
return broken_b; //sam
On Tuesday, 5 August 2014 at 23:47:00 UTC, Artur Skawina via
Digitalmars-d-learn wrote:
Is there any way I can gain access on i inside B?
Not directly, but as you ask for /any/ way -- yes:
struct B
{
void foo() { outer.i ~= 1; }
ref A outer() inout @property { return
*cast(A
On Tuesday, 5 August 2014 at 22:14:23 UTC, abanstadya wrote:
programming Q, either youra newb or not, should rather be
posted to 'http://forum.dlang.org/group/digitalmars.D.learn'.
Your post appears on
'http://forum.dlang.org/group/digitalmars.D' which is more
related to the lang. design rath
> why it does not wor :).
why it does not *work*, of course. Sigh.
On Tue, Aug 5, 2014 at 11:37 PM, Martijn Pot via Digitalmars-d-learn
wrote:
> Does this help :
> http://www.digitalmars.com/d/archives/digitalmars/D/learn/Nested_struct_member_has_no_access_to_the_enclosing_class_data_38294.html
Yes, that helps: that explains why it does not wor :).
I changed my
I'd have thought that this would work:
struct A
{
int[] i;
B b;
struct B
{
void foo() { i ~= 1;}
}
}
void main()
{
A a;
a.b.foo();
}
But the compiler tells me 'need this for i of type int[]'.
Is there any way I can gain access on i inside B?
> http://pastebin.com/34sbffSa
Your problem comes from lengthSquared:
public auto lengthSquared = function () => val.reduce!((a,b) => a + b*b);
That's an unusual way to define a method. Any reason why you are using
a pointer to a function as a member? Do you need to be able to
redefine it at run
> Some range which takes an at compile time known number of elements from an
> input range and provides opIndex seems perfect to me, but as far as I know
> there's no such thing in Phobos.
There is chunks:
http://dlang.org/phobos/std_range.html#chunks
> Is there multiline comments available inside PEGGED template?
> As far as I understand inline comments are set via # sign.
No, no multiline comment. That's based on the original PEG grammar,
which allows only #-comments.
> https://github.com/D-Programming-Language/phobos/pull/1910
Very interesting discussion, thanks. I'm impressed by the amount of
work you guys do on github.
On Mon, Aug 4, 2014 at 6:38 PM, Russel Winder via Digitalmars-d-learn
wrote:
> Are these std.concurrent threads or std.parallelism tasks?
>
> A std.parallelism task is not a thread. Like Erlang or Java Fork/Join
> framework, the program specifies units of work and then there is a
> thread pool un
On Mon, Aug 4, 2014 at 6:21 PM, Dicebot via Digitalmars-d-learn
wrote:
> vibe.d additions may help here:
>
> http://vibed.org/api/vibe.core.core/runTask
> http://vibed.org/api/vibe.core.core/runWorkerTask
> http://vibed.org/api/vibe.core.core/workerThreadCount
>
> "task" abstraction allows exactl
On Mon, Aug 4, 2014 at 3:36 PM, Dicebot via Digitalmars-d-learn
wrote:
> Most likely those threads either do nothing or are short living so you don't
> get actually 10 000 threads running simultaneously. In general you should
> expect your operating system to start stalling at few thousands of
>
On Mon, Aug 4, 2014 at 2:13 PM, Chris Cain via Digitalmars-d-learn
wrote:
>> OK, I get it. Just to be sure, there is no ThreadPool in Phobos or in
>> core, right?
> There is. It's called taskPool, though:
>
> http://dlang.org/phobos/std_parallelism.html#.taskPool
Ah, std.parallelism. I stoopidl
> Without going into much detail: Threads are heavy, and creating a thread is
> an expensive operation (which is partially why virtually every standard
> library includes a ThreadPool).
> I haven't looked into detail your code, but consider using the TaskPool if
> you just want to schedule some ta
On Mon, Aug 4, 2014 at 7:13 AM, Uranuz via Digitalmars-d-learn
wrote:
> I am real noob about grammar description languages so I need some
> explanation about it. As far as I understand expressions in curly bracers
> are used to modify syntax tree just in process of parsing instead of
> modifying i
> This is correct – the LLVM optimizer indeed gets rid of the loop completely.
OK,that's clever. But I get this even when put a writeln("some msg")
inside the task. I thought a write couldn't be optimized away that way
and that it's a slow operation?
Anyway, I discovered Thread.wait() in core in
Uranuz:
> http://akdubya.github.io/dustjs/
> So I need some help with rewriting grammar from PEGjs into PEGGED.
Is this the grammar?
https://github.com/akdubya/dustjs/blob/master/src/dust.pegjs
If so, then I think I can provide some help. But I don't get what
output you want (see below).
> Als
I'm trying to grok message passing. That's my very first foray
into this, so I'm probably making every mistake in the book :-)
I wrote a small threadpool test, it's there:
http://dpaste.dzfl.pl/3d3a65a00425
I'm playing with the number of threads and the number of tasks,
and getting a feel abo
I'm trying to grok message passing. That's my very first foray
into this, so I'm probably making every mistake in the book :-)
I wrote a small threadpool test, it's there:
http://dpaste.dzfl.pl/3d3a65a00425
I'm playing with the number of threads and the number of tasks,
and getting a feel about
On Wed, Jul 30, 2014 at 11:46 AM, Philippe Sigaud
wrote:
>> I expected such an answer and I do understand the decisions behind it. Yet,
>> you gave me a really GOOD news! Having to write cast(ubyte) 1 was way too
>> much verbose for my liking, while the new ubyte(1) is reasonab
> I expected such an answer and I do understand the decisions behind it. Yet,
> you gave me a really GOOD news! Having to write cast(ubyte) 1 was way too
> much verbose for my liking, while the new ubyte(1) is reasonable enough.
Why not use `1u`?
> I did, and I got it to work. Unfortunately, the code used to in the CTFE is
> left in the final executable even though it is not used at runtime. So now
> the question is, is there away to get rid of the excess baggage?
Not that I know of. Once code is injected, it's compiled into the executable
> Hmm.
> So how do I use stuff like this:
>
> template defaultInit(T)
> {
> static if (!is(typeof({ T v = void; })))// inout(U)
> @property T defaultInit(T v = T.init);
> else
> @property T defaultInit();
> }
>
> (this is from std.traits - ok,
On Mon, Jul 14, 2014 at 3:19 PM, Artur Skawina via Digitalmars-d-learn
wrote:
> On 07/14/14 13:42, Philippe Sigaud via Digitalmars-d-learn wrote:
>> asserts get an entire copy of the parse tree. It's a bit wasteful, but
>> using 'immutable' directly does
> I am trying to write some code that uses and matches to regular expressions
> at compile time, but the compiler won't let me because matchFirst and
> matchAll make use of malloc().
>
> Is there an alternative that I can use that can be run at compile time?
You can try Pegged, a parser generator
Halas, that's not what the OP wants. He needs properties on the *type*
itself: int.foo instead of foo!int.
So no, this is not possible.
On Tue, Jul 8, 2014 at 7:50 AM, H. S. Teoh via Digitalmars-d-learn
wrote
Wow, what to add to that? Maybe you scared other from participating ;-)
* I'll second metaprogramming: the alliance between templates, CTFE
and mixins is really nice. It's *the* feature (or triplet of features)
I think of
Seeing his example, the OP wants a solution that works even for templates:
template Test1(T) {}
pragma(msg, instanceArgsOf!(Test1, Test1!int));
which fails because Test1!int is not a type (std.traits.isInstanceOf
fails also, for the same reason).
And is(symbol == Name!Args, Args...) does not wor
On Sat, Jul 5, 2014 at 6:35 PM, Andre Tampubolon via
Digitalmars-d-learn wrote:
> I've been reading the newsgroup for a while, and it seems that one of the
> reason folks like D is because it supports module.
>
> My question is: what does module mean?
> A quick google pointed my this page: http://
If you compile your project with the -deps flag, the compiler will
output import dependencies. With -deps=filename, the output will go
into filename.
>From there, you'll have to parse and create the graph, though. Maybe
have a look into rdmd source, to see how the dependency extraction is
done the
>> Just an idea that popped into my head... Maybe I can use variant for the
>> input/output types? I haven't looked at it yet, so I'm not sure what it
>> does, or the performance costs.
>
> It imitates you standard variant type from dynamic languages. It sure
> would make translating Javascript co
On Tue, Jun 24, 2014 at 2:55 AM, Christian Beaumont via
Digitalmars-d-learn wrote:
> Just an idea that popped into my head... Maybe I can use variant for the
> input/output types? I haven't looked at it yet, so I'm not sure what it
> does, or the performance costs.
It imitates you standard varia
> Yes, the final callback is always called, but if an error is passed to the
> callback by any of the main steps in the "sequence ladder", it will
> immediately jump to the final callback and not execute further steps.
OK.
>> What do you mean? The compiler does deduce the type of Funcs.
>
>
> If
On Mon, Jun 23, 2014 at 9:39 PM, Christian Beaumont via
Digitalmars-d-learn wrote:
> Each function is given a callback, that when called, steps the waterfall
> forward on to the next function to process. If an error is passed to the
> callback (instead of null), then the waterfall stops processi
On Sun, Jun 22, 2014 at 5:02 PM, monnoroch via Digitalmars-d-learn
wrote:
> Thanks a lot!
> There is a problem though: when i pass incorrect parameters to
> such a method, it says, that S has no such field, which is a
> misleading error message.
You can test the mixin with static if, like this:
On Sun, Jun 22, 2014 at 5:04 PM, monnoroch via Digitalmars-d-learn
wrote:
> There is also a problem: when i declare opDispatch to be private,
> i still have access to this forwarding from another package. Is
> it a bug or what?
I don't know. I never used private in conjunction with a template.
Le
You can use 'auto' to let the compiler deduce the return type. Here I
use 'foo' which returns an int and 'bar', which returns void.
struct SomeT {
int foo(double d) { return 0;}
void bar(double d) { return;}
}
struct S {
auto /* here */
opDispatch(string name, Args...)(Args arg
I see, thanks Artur.
On Sat, Jun 21, 2014 at 4:24 PM, Dicebot via Digitalmars-d-learn
wrote:
> On Saturday, 21 June 2014 at 13:45:14 UTC, Philippe Sigaud via
> Digitalmars-d-learn wrote:
>>
>> Out of curiosity, why use a mixin template containing a string mixin
>> instead of, well, directly
Out of curiosity, why use a mixin template containing a string mixin
instead of, well, directly injecting a string mixin in your struct,
with a function?
Use a string mixin?
string fun(string name)
{
return "public static int " ~ name ~ "() { return 0; }";
}
struct S {
mixin (fun("fctn1"));
}
void main() {
S s;
import std.stdio;
writeln(s.fctn1());
}
> And I don't think it should, because the heap allocation that you're
> probably expecting should be explicit IMO. For me it's also unintuitive,
> because I would read it as constructing a pointer that points to the address
> 3.
I agree. I'm trying to get a feel on the limits of this new
'type(va
Would
auto i = (int*)(3);
make sense?
Does it work?
Hi Vlad,
you can try David Nadlinger's std.units:
http://klickverbot.at/code/units/std_units.html
See the discussion at
http://forum.dlang.org/thread/io1vgo$1fnc$1...@digitalmars.com
>From what I deemly remember of Boost/units, it's a bit less complete,
but far easier to use.
>> // wrong code gen(*) with -release -O -inline -noboundscheck or
>> // with -release -inline -noboundscheck but only if std.file is imported:
>>
>> auto x = countUntil( names, "FOO" );
>> write(x);
>> if( 0 <= x ) writeln(" found a FOO"); // (*) not found!
>> }
>
>
> I'm runnin
>> Is there any reason you couldn't (or would rather not) use structs rather
>> than tuples?
>
>
> That would work. What would be the best way to auto-generate the types? I
> have somewhere around 30 already, and the number will grow with this
> project.
>
> Evan Davis
Maybe you could use a struct
> enum b = DataAndView(1);
> assert (!sameTail(b.data, b.view));
I suppose it's because enums are manifest constants: the value they
represent is 'copy-pasted' anew everywhere it appears in the code. So
for arrays and associative arrays, it means recreating a new value
each and eve
In any case, it's an internal compiler error, so it's a bug. Users
should never see ICEs.
Could you please report it, with the entire error message?
On Sun, Jun 1, 2014 at 12:34 AM, Timon Gehr via Digitalmars-d-learn
wrote:
> This behaviour is independent of templates. Struct values of the same size
> can be reinterpret-cast to each other this way even if their types are
> completely unrelated.
Do you know if this is by design?
But let's keep in mind it's a *runtime* value. You cannot use it at
compile-time as a boolean for a 'static if'.
So:
if (__ctfe) // yes
{
// compile-time path
}
else
{
// runtime path
}
But not:
static if (__ctfe) // no
{
// compile-time path, including new global declarations
}
else
On Sat, May 31, 2014 at 10:14 PM, bearophile via Digitalmars-d-learn
wrote:
>> 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-t
See: http://dlang.org/function.html#variadicnested
The second example explains that nested functions can be accessed only
if the name is in scope.
>> 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
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 Friday, 30 May 2014 at 20:02:40 UTC, Steven Schveighoffer
wrote:
If you want an opaque struct, you need to return it by pointer.
What do you mean? Like this?
Hidden* foo() { return new Hidden();}
?
Otherwise, the user must be able to know what type it is
(otherwise, how would he use it
On Friday, 30 May 2014 at 19:54:00 UTC, safety0ff wrote:
On Friday, 30 May 2014 at 19:50:43 UTC, Philippe Sigaud wrote:
Am I misunderstanding something or is that a bug?
Try: auto foo() { return Hidden();}
I'm not seeing any difference? I'm still able to create a value
of type Hi
I'm trying to 'hide' a type, so as not to see it outside its
module. I want to control the way it's created and used.
I know of Voldemort types and '@disable this', but for now I'm
just trying to use 'private'. Halas, it seems it can be
circumvented:
*
module A;
private struct Hidd
On Fri, May 30, 2014 at 7:56 PM, Steven Schveighoffer wrote:
> You can as long as the value is known at compile time:
>
> http://dpaste.dzfl.pl/5a710bd80ab0
Oh wow.
And that works for static if also:
http://dpaste.dzfl.pl/f87321a47834
Man. That opens some new possibilities.
On Fri, May 30, 2014 at 7:28 PM, Ali Çehreli
wrote:
> On 05/30/2014 08:30 AM, Russel Winder via Digitalmars-d-learn wrote:
>
>> enum double p0 = 0.0045;
>
> As others have already said, p0 is a manifest constant. Interestingly, it
> can be thought of like a C macro, being pasted inside so
A good use of 'static immutable', sadly not voted into the language.
:-)
But you're right, and I remember being tripped by this.
1 - 100 of 516 matches
Mail list logo