Re: public alias to private template implementation
On Monday, 16 September 2013 at 23:53:14 UTC, Meta wrote: So you're really directly accessing a private symbol. Perhaps a workaround could be something like this: // module Test; static const fun = Impl!int; private template Impl(T) { void Impl(){} } // module main; import Test; void main() { fun(); } I had to do fun = Impl!int because the compiler complained about fun = Impl!int. This seems to be not working, because Impl actually holds an overload. It's actually something like: private template Impl(T) { void Impl(){} void Impl(int){} } Grown.
Re: User defined attributes use
On 2013-09-16 22:15, Namespace wrote: Then of course I have not said anything. The same thing I would suggest for scope. It exists as a library solution and is rewritten magical. I think the big difference here is that AA's are safe where scope is not. I agree with you, I like to use scope anyway. -- /Jacob Carlborg
Re: User defined attributes use
On 2013-09-17 00:53, H. S. Teoh wrote: Hmm. I find D arrays just fine the way they are, actually. (In fact, I rather *liked* the way D arrays worked as compared with, say, C/C++.) What's wrong with them? I guess one can complain about some of the built-in properties/functions, like sort. -- /Jacob Carlborg
How to compile this template with short type?
[code] Unsigned!T encodeZigZag( T )( inout T v ) pure if( isSigned!( T ) ) { return v 0 ? v * 2 : -v * 2 - 1; } unittest { assert( encodeZigZag!long( 2147483647 ) == 4294967294 ); assert( encodeZigZag!long( -2147483648 ) == 4294967295 ); assert( encodeZigZag!short( 20 ) == 40 ); assert( encodeZigZag!short( -20 ) == 39 ); } [/code] Error: cannot implicitly convert expression (cast(int)v 0 ? cast(int)v * 2 : cast(int)-v * 2 - 1) of type int to ushort int?!
Re: How to compile this template with short type?
On Tuesday, 17 September 2013 at 07:58:40 UTC, mrd wrote: [code] Unsigned!T encodeZigZag( T )( inout T v ) pure if( isSigned!( T ) ) { return v 0 ? v * 2 : -v * 2 - 1; } unittest { assert( encodeZigZag!long( 2147483647 ) == 4294967294 ); assert( encodeZigZag!long( -2147483648 ) == 4294967295 ); assert( encodeZigZag!short( 20 ) == 40 ); assert( encodeZigZag!short( -20 ) == 39 ); } [/code] Error: cannot implicitly convert expression (cast(int)v 0 ? cast(int)v * 2 : cast(int)-v * 2 - 1) of type int to ushort int?! Unsigned!T encodeZigZag( T )( inout T v ) pure if( isSigned!( T ) ) { return cast(Unsigned!T)(v 0 ? v * 2 : -v * 2 - 1); }
Re: How to compile this template with short type?
ahhh, many thanks! I need more sleep
Re: public alias to private template implementation
On 16/09/13 23:00, monarch_dodra wrote: Question 1: Is this the correct behavior? I'd have expected that if my alias is public, it would allow any one from outside to make the call correctly. See: http://d.puremagic.com/issues/show_bug.cgi?id=10996 Question 2: Is there a correct way to do this? I possible, I'd want to avoid nesting the template, eg: auto fun(){return Impl!int();} As that would: a) require more typing ^^ b) incur an extra function call in non-inline c) if at all possible, I actually need fun to be a template, so that it can be inlined. Indeed, I used that workaround of manually nesting the functions in some code of mine: https://github.com/WebDrake/Dgraph/blob/master/dgraph/graph.d#L492-L516 ... but that's not a general solution, I was able to tolerate it because it's a limited and predictable set of instructions. Jacob Carlborg suggested using opDispatch (cf. how it's done in Proxy), which should automate the nesting of template functions. I avoided it simply because in my case I thought that doing it manually would be less hassle than getting opDispatch set up to cover every possible case, but depending on your use case it might be the better option.
Re: public alias to private template implementation
On Tuesday, 17 September 2013 at 08:47:25 UTC, Joseph Rushton Wakeling wrote: On 16/09/13 23:00, monarch_dodra wrote: Question 1: Is this the correct behavior? I'd have expected that if my alias is public, it would allow any one from outside to make the call correctly. See: http://d.puremagic.com/issues/show_bug.cgi?id=10996 Question 2: Is there a correct way to do this? I possible, I'd want to avoid nesting the template, eg: auto fun(){return Impl!int();} As that would: a) require more typing ^^ b) incur an extra function call in non-inline c) if at all possible, I actually need fun to be a template, so that it can be inlined. Indeed, I used that workaround of manually nesting the functions in some code of mine: https://github.com/WebDrake/Dgraph/blob/master/dgraph/graph.d#L492-L516 ... but that's not a general solution, I was able to tolerate it because it's a limited and predictable set of instructions. Jacob Carlborg suggested using opDispatch (cf. how it's done in Proxy), which should automate the nesting of template functions. I avoided it simply because in my case I thought that doing it manually would be less hassle than getting opDispatch set up to cover every possible case, but depending on your use case it might be the better option. Thanks. I'm not very fluent with opDispatch though. Doesn't that only work if you have an struct/class instance though? My fun is a free frunction. I you are able to adapt it to my trivial usecase, it might be clearer to me what you have in mind.
Re: public alias to private template implementation
On 17/09/13 11:30, monarch_dodra wrote: Thanks. I'm not very fluent with opDispatch though. Doesn't that only work if you have an struct/class instance though? My fun is a free frunction. Ack. Sorry, I overlooked that. :-( Still, I think this provides greater impulse for Issue 10996 to be fixed, since your issue clearly stems from the same access implementation issues. If you make a public alias, you'd expect public members of whatever you're aliasing to be public through that alias. I guess it might be desirable to require some clear indication Yes, I really, really know what I'm doing and I do want this alias to be public -- e.g. compelling you to use the public keyword explicitly.
License of RosettaCode examples (for bearophile:-)
This message is especially for bearophile, but applies to anyone posting examples on RosettaCode :-) Can I ask you to clarify your licensing intentions for these examples? By default all on RosettaCode is GNU Free Documentation License, which does not really play in a friendly way with ... just about any actual software license. I imagine that all these examples were posted with the intention that they be used by others, but the default RosettaCode situation makes that impossible without direct permission. So ... I'm asking. :-) Thanks best wishes, -- Joe
Re: GC.collect bug ?
I cannot use the delete/destroy. I want to call dtor at all unreferenced objects. Manual from Dlang size says that GC.collect triggers a full collection. But it doesn't.
Re: License of RosettaCode examples (for bearophile:-)
On Tuesday, 17 September 2013 at 11:04:13 UTC, Joseph Rushton Wakeling wrote: This message is especially for bearophile, but applies to anyone posting examples on RosettaCode :-) Can I ask you to clarify your licensing intentions for these examples? By default all on RosettaCode is GNU Free Documentation License, which does not really play in a friendly way with ... just about any actual software license. I imagine that all these examples were posted with the intention that they be used by others, but the default RosettaCode situation makes that impossible without direct permission. So ... I'm asking. :-) An example of what the situation is using GNU FDL - last time I checked material under the GNU FDL could not be put into GPL code and GPL code could not be put into a GNU FDL manual. So watch out! :-) Regards Iain.
Re: public alias to private template implementation
That is actually very weird because you can override protection attribute with alias for an aggregate: // b.d private struct A_ { } public alias A = A_; // a.d void main() { A a; } // fine! That inconsistency feels plain wrong. Worth enhancement request at least.
Re: License of RosettaCode examples (for bearophile:-)
Joseph Rushton Wakeling: This message is especially for bearophile, but applies to anyone posting examples on RosettaCode :-) Can I ask you to clarify your licensing intentions for these examples? By default all on RosettaCode is GNU Free Documentation License, which does not really play in a friendly way with ... just about any actual software license. I am just following the common licensing you see in that site: http://www.gnu.org/licenses/fdl-1.2.html Recently the author of most of the PicoLisp entries has collected them in a commercial book, this has caused some troubles. If you want info about Rosettacode licensing I suggest you go in the rosettacode IRC channel and talk with Mike Mol about it. Bye, bearophile
Re: N step fft in D language
On Sunday, 15 September 2013 at 20:58:54 UTC, Kadir Erdem Demir wrote: On Sunday, 15 September 2013 at 15:39:14 UTC, John Colvin wrote: On Sunday, 15 September 2013 at 15:15:28 UTC, Kadir Erdem Demir wrote: I am using fft function from std.numeric Complex!double[] resultfft = fft(timeDomainAmplitudeVal); The parameter timeDomainAmplitudeVal is audio amplitude data. Sample rate 44100 hz and there is 131072(2^16) samples I am seeing that resultfft has the same size as timeDomainAmplitudeVal(131072) which does not fits my project(also makes no sense). That's what the FFT does. See here: http://stackoverflow.com/questions/4364823/how-to-get-frequency-from-fft-result I believe I am well aware of the things which are explained in the link. There is a sentence in link which says : The first bin in the FFT is DC (0 Hz), the second bin is Fs / N, where Fs is the sample rate and N is the size of the FFT. My question how can I determine the N which is the size of FFT ? In fftw library one can define N like : fftw_create_plan(N, FFTW_FORWARD, FFTW_ESTIMATE); In D do we have a way to do that ? Hi! Haven't tried this, but looking at the docs it looks like you have to: auto mySample = getSampleData(); auto fftData0 = fft(mySample[0..512]); auto fftData1 = fft(mySample[512..1024]); ... This would give you the frequency correlation data for two windows in time, and by reading that stackoverflow I assume for 256 frequencies each. Docs also says there's a class you can reuse if you know the max size, which should be faster. auto ffter = new Fft(512); foreach(chunk; getSampleByChunk(512)) { auto fftData = ffter.fft(chunk); ... } The FFT size, N, is the same as the number of samples you provide it. So the more data you provide, the finer correlation detail you get. I think it makes sense? Hmm, what it seems you have done is pass the entire sample though, which gives you an FFT of size 131072. So you get phenomenally good detail in frequency correlation, but just one huge time window—the entire sample! I think what you're simply looking for is chopping it up into smaller pieces and run fft on each—that's at least what most audio tools do I believe. kind regards k
Re: User defined attributes use
On 09/17/13 00:53, H. S. Teoh wrote: On Mon, Sep 16, 2013 at 10:59:10PM +0200, Artur Skawina wrote: On 09/16/13 22:38, Namespace wrote: [1] Obviously, not a practical short term option for the existing D2 language. That's probably clear from the context, and the question was meant to be rhetorical -- but it could actually be done and would make sense; it's just not a change that would make enough of a difference on its own; the cost would be to high. Why to high? Too much compiler magic or dmd internal dependences? Too much (language) change for too little gain; there are many, many much more important things that need to be fixed. Being able to have several user-defined kinds of arrays is a nice-to-have feature, but not one that determines whether the language is usable or not. [...] Hmm. I find D arrays just fine the way they are, actually. (In fact, I rather *liked* the way D arrays worked as compared with, say, C/C++.) What's wrong with them? Not that much, at least not enough to worry about it right now, considering all the other language issues. (eg some conversions, like to-bool, static-array-to-slice; syntax ambiguity [1]; some properties) But removing magic from the compiler and making the language more expressive, so that the magic could be done by the user, would be an improvement. Not a regression, which the original question implied. For example: 1) // in semi-pseudocode alias utf8string = utf8octet[]; utf8string s = abc; foreach (c; s) // iterate by codepoints, not bytes Yep, this is like what can be done today with built-in strings -- except that it could be done by overloading array-ops in 'utf8octect'. No type-specific compiler magic, and then you can use it for many other kinds of variable-element-length array types. 2) SIMD optimizations; again, w/o explicit compiler support. It could just map array ops to an optional 'static @inline T.opArrayOp(string op, size_t minAlignent, B)(T[] a, B b)' method, etc. In general, much of the built-in compiler 'magic' gets in the way of emitting optimal code, for example the hardwired (d)runtime calls prevent many optimizations. (eg removing (hacking around for just one built-in type is easy enough) the 'typeid()' calls from your stand-alone AAs makes a huge difference. Or at least it did ~ a year ago when i looked at how much inherent overhead the std AAs have). artur [1] -- auto f(T[2] a) { /* 'a' is what it looks like - a static array, right? Oops... */ } template Tuple(A...) { alias Tuple = A; } alias T = Tuple!(int, double, long); --
Re: License of RosettaCode examples (for bearophile:-)
On 17/09/13 13:17, Iain Buclaw wrote: An example of what the situation is using GNU FDL - last time I checked material under the GNU FDL could not be put into GPL code and GPL code could not be put into a GNU FDL manual. So watch out! :-) Indeed. An unfortunate situation, no?
Re: License of RosettaCode examples (for bearophile:-)
On 17/09/13 13:32, bearophile wrote: I am just following the common licensing you see in that site: http://www.gnu.org/licenses/fdl-1.2.html Recently the author of most of the PicoLisp entries has collected them in a commercial book, this has caused some troubles. If you want info about Rosettacode licensing I suggest you go in the rosettacode IRC channel and talk with Mike Mol about it. Would you be prepared to license your own examples under Boost? I don't know what your intentions were for others' use of your code, but as it stands the FDL license makes them impossible to re-use.
Re: License of RosettaCode examples (for bearophile:-)
Joseph Rushton Wakeling: Would you be prepared to license your own examples under Boost? I don't know what your intentions were for others' use of your code, but as it stands the FDL license makes them impossible to re-use. I am writing code for Rosettacode since years, I have written, rewritten, I have modified code written by others, and so on. I have also written many entries before having an account in that site, so there's no proof the author is me. I have also written many entries in Python, several in Haskell and C, some in C++, etc. While there are several entries that are written only by me, finding them is not easy. I didn't care about the owners of the code there. So I own nothing there. For re-use ask to Mike Mol. Bye, bearophile
Re: License of RosettaCode examples (for bearophile:-)
On 17/09/13 14:03, bearophile wrote: I am writing code for Rosettacode since years, I have written, rewritten, I have modified code written by others, and so on. I have also written many entries before having an account in that site, so there's no proof the author is me. I have also written many entries in Python, several in Haskell and C, some in C++, etc. While there are several entries that are written only by me, finding them is not easy. I didn't care about the owners of the code there. So I own nothing there. For re-use ask to Mike Mol. I have a specific interest in your circular queue implementation: http://rosettacode.org/wiki/Queue/Usage#Faster_Version I used this (or rather, I adapted it) in a private project which is not being distributed, so hence there were no licensing issues. I can't remember how I found it but I think it was when you posted it to the digitalmars.D mailing list: http://forum.dlang.org/post/grepielsmapflndpk...@forum.dlang.org ... and at the time I think I just assumed that since you were pointing people to it and were the author, you'd licensed it permissively. However, more recently I rather stupidly copied my adapted version into a public project of mine, and I suddenly realized the licensing situation. In the worst case scenario, I'll strip it out of the code, but I was hoping that you might be willing to license this specific code under Boost or something else GPL-compatible.
Re: License of RosettaCode examples (for bearophile:-)
Joseph Rushton Wakeling: I have a specific interest in your circular queue implementation: http://rosettacode.org/wiki/Queue/Usage#Faster_Version If you restrict your desires to just one D program, instead of the about one thousand of Rosettacode the situation becomes _much_ simpler :-) I wrote that D code myself because Phobos still lacks a queue, but the original idea of growable circular queues is decades old. For Phobos I suggest a different and more complex implementation (dynamic array of pointers to freelist-linked fixed sized chunks). However, more recently I rather stupidly copied my adapted version into a public project of mine, and I suddenly realized the licensing situation. In the worst case scenario, I'll strip it out of the code, but I was hoping that you might be willing to license this specific code under Boost or something else GPL-compatible. I have put that code only on Rosettacode, and in an archive in my site. I am willing to release it to public domain if you want :-) But what do you want me exactly to do? :-) Bye, bearophile
Re: License of RosettaCode examples (for bearophile:-)
On 17/09/13 15:18, bearophile wrote: Joseph Rushton Wakeling: I have a specific interest in your circular queue implementation: http://rosettacode.org/wiki/Queue/Usage#Faster_Version If you restrict your desires to just one D program, instead of the about one thousand of Rosettacode the situation becomes _much_ simpler :-) Very true. :-) I'm sorry for not being sufficiently specific straight away, but I thought the general question might be of interest. I did try and write you a personal email about the specific code earlier today, before even writing to the list, but your given email address doesn't work. I take it that I need to make some manual tweaks to what appears in the Reply: field ... ? I wrote that D code myself because Phobos still lacks a queue, but the original idea of growable circular queues is decades old. For Phobos I suggest a different and more complex implementation (dynamic array of pointers to freelist-linked fixed sized chunks). I made use of it ... because Phobos still lacks a queue. :-P And I'll surely use Phobos' queue in its place once that is implemented. I have put that code only on Rosettacode, and in an archive in my site. I am willing to release it to public domain if you want :-) But what do you want me exactly to do? :-) Well, I guess the best thing would be just to write here, I license the code under the terms of the Boost license or something similar (public domain is in some ways less good because not every jurisdiction recognizes it, but as far as I'm concerned it's fine too). I'm just looking for something that I can reference to say the code is used under these terms. If you could add such a notice to the copy on your own site and on RosettaCode it would be even better because that means that it's then clear to everyone what the use terms of the code are (I think RosettaCode allows you to add more permissive licenses to your code submissions, no?). But that's up to you. An explicit permission here is all I'm really looking for. Whatever you decide, thanks very much for being so understanding and accommodating. I'm very embarrassed about this, it is very unlike me to neglect code licensing in this way. :-( Thanks best wishes, -- Joe
Re: License of RosettaCode examples (for bearophile:-)
Joseph Rushton Wakeling: Well, I guess the best thing would be just to write here, I license the code under the terms of the Boost license or something similar (public domain is in some ways less good because not every jurisdiction recognizes it, but as far as I'm concerned it's fine too). I'm just looking for something that I can reference to say the code is used under these terms. I license the D program Queue/Usage (Faster Version) of the RosettaCode site under the terms of the Boost license. It implements in D2 a simple Circlular Queue able to grow geometrically. The code is visible in this page: http://rosettacode.org/wiki/Queue/Usage#Faster_Version If you could add such a notice to the copy on your own site and on RosettaCode it would be even better Nearly all Rosettacode site entries (and all D entries) lack a license notice. It's just bad noise added. For questions ask to Mike in the #rosettacode IRC channel. Bye, bearophile
Re: Windows DLLs with D
On Saturday, 14 September 2013 at 16:46:06 UTC, Buk wrote: Hi all, I've read http://dlang.org/dll.html, and frankly there seems to be a lot of boilerplate rote process to build a DLL. I realise that many of the do nothing functions /can/ be used to do a lot more; and these may be required for some purposes. But, for a simple DLL of functions, that can be built in C as simply as: C:\test\demotype mydll.c int __declspec(dllexport) add( int a, int b ) { return a + b; } C:\test\democl /MT /LD mydll.c mydll.c /out:mydll.dll /dll /implib:mydll.lib mydll.obj Creating library mydll.lib and object mydll.exp C:\test\demodumpbin /exports mydll.dll Dump of file mydll.dll File Type: DLL Section contains the following exports for mydll.dll 1 ordinal base 1 number of functions 1 number of names ordinal hint RVA name 10 1000 add Is there any similar mechanism for these 'simple' cases for D? If not, shouldn't it be possible to create an ?interface? file that takes care of the boilerplate? (If so, does anyone have one they can share?) Thanks, Buk. Thanks for the help guys.
Re: Windows DLLs with D
On Tuesday, 17 September 2013 at 16:05:13 UTC, Buk wrote: Thanks for the help guys. Sorry for the silence. It has just happened that your question touches relatively under-explored area of the language and thus finding someone with actual experience on topic is hard. I don't even know if we have any official DLL support on Windows (other than workarounds presented on page you have linked), to be honest. Hope this topic will attract some Windows users eventually :)
Re: GC.collect bug ?
On Sep 17, 2013, at 4:14 AM, Temtaime temta...@gmail.com wrote: I cannot use the delete/destroy. I want to call dtor at all unreferenced objects. Manual from Dlang size says that GC.collect triggers a full collection. But it doesn't. It does. But the collector isn't guaranteed to collect everything that is no longer referenced during a given collection cycle. It's possible a register still holds the reference to that object. Try doing a bit more stuff before collecting and see if that changes behavior. Or allocate a second dummy object.
Re: Windows DLLs with D
On 14.09.2013 18:46, Buk wrote: Hi all, I've read http://dlang.org/dll.html, and frankly there seems to be a lot of boilerplate rote process to build a DLL. I realise that many of the do nothing functions /can/ be used to do a lot more; and these may be required for some purposes. But, for a simple DLL of functions, that can be built in C as simply as: C:\test\demotype mydll.c int __declspec(dllexport) add( int a, int b ) { return a + b; } C:\test\democl /MT /LD mydll.c mydll.c /out:mydll.dll /dll /implib:mydll.lib mydll.obj Creating library mydll.lib and object mydll.exp C:\test\demodumpbin /exports mydll.dll Dump of file mydll.dll File Type: DLL Section contains the following exports for mydll.dll 1 ordinal base 1 number of functions 1 number of names ordinal hint RVA name 10 1000 add Is there any similar mechanism for these 'simple' cases for D? If not, shouldn't it be possible to create an ?interface? file that takes care of the boilerplate? (If so, does anyone have one they can share?) Thanks, Buk. Actually the code snippet for DllMain on that page is the needed boilerplate code if you don't need any tweaking of the defaults. If you add code in mydll.d like: export extern(C) add(int a, int b) { return a + b; } and build this with: dmd -ofmydll.dll -d mydll.d dllmain.d you get a dll with the export: dumpbin /exports mydll.dll Dump of file mydll.dll File Type: DLL Section contains the following exports for mydll.dll characteristics 0 time date stamp Thu Jan 01 01:00:00 1970 0.00 version 1 ordinal base 1 number of functions 1 number of names ordinal hint RVA name 10 3010 _add [The -d in the command line has nothing to do with building DLLs, but is needed because the DllMain snippet causes a deprecation message.] If you are looking for something as described in the D code calling D code in DLLs section, I'd have to issue a warning: this does not really work sensibly yet, but it is being worked on.
Re: Compile time data structure
On 09/16/2013 01:24 PM, Marek Janukowicz wrote: static string[string] columns () { // ... } Although the function itself is static, it returns a dynamic value. foreach( attr, col; columns() ) { __traits(getMember, me, attr) = typeof(__traits(getMember, me, attr)).init; } That foreach is a run-time foreach because columns()'s return value is a run-time value. As far as I know, static foreach is only for tuples (or TypeTuples). If you can generate the AA as a tuple, then the foreach will be evaluated at compile time. Ali
Re: Compile time data structure
On Wednesday, 18 September 2013 at 01:24:37 UTC, Ali Çehreli wrote: As far as I know, static foreach is only for tuples (or TypeTuples) TypeTuples are tuples. Sortof. We really need to get that whole situation sorted
Re: Compile time data structure
On Wed, Sep 18, 2013 at 04:12:01AM +0200, John Colvin wrote: On Wednesday, 18 September 2013 at 01:24:37 UTC, Ali Çehreli wrote: As far as I know, static foreach is only for tuples (or TypeTuples) TypeTuples are tuples. Sortof. We really need to get that whole situation sorted Not to mention there are also parameter tuples that behave sorta like TypeTuples but not quite. T -- In a world without fences, who needs Windows and Gates? -- Christian Surchi
I cannot understand problem with argument of the function
// Simple function called for unsigned integers: static ubyte[] packVarint(T)( T value ) if( isIntegral!T isUnsigned!T ) out( arr ) { T d; size_t size = d.unpackVarint( arr[0] ); import std.stdio; import std.conv; writeln( out contract, type=, typeid(T), isUnsigned=, isUnsigned!T, arg=, value, result=, arr ); stdout.flush; assert( size == arr.length ); assert( d == value ); } body { import std.stdio; import std.conv; writeln( value inside of body: , value ); stdout.flush; ubyte[] res; immutable ubyte maximal = 0b_1000_; while( value = maximal ) { res ~= cast( ubyte )( value | maximal ); value = 7; } res ~= cast( ubyte ) value; return res; } unittest { auto v = packVarint!ulong( 300 ); assert( v.length == 2 ); assert( v == [ 0b_10101100, 0b_0010 ] ); } output: value inside of body: 1 // arg=1 out contract, type=uint isUnsigned=true arg=1 result=[1] // works for arg=1 ! value inside of body: 2 out contract, type=uint isUnsigned=true arg=2 result=[2] value inside of body: 1 out contract, type=uint isUnsigned=true arg=1 result=[1] value inside of body: 2 out contract, type=uint isUnsigned=true arg=2 result=[2] value inside of body: 12 out contract, type=ulong isUnsigned=true arg=12 result=[12] value inside of body: 30 out contract, type=ulong isUnsigned=true arg=30 result=[30] value inside of body: 14 out contract, type=ulong isUnsigned=true arg=14 result=[14] value inside of body: 30 out contract, type=ulong isUnsigned=true arg=30 result=[30] value inside of body: 12 out contract, type=ulong isUnsigned=true arg=12 result=[12] value inside of body: 30 out contract, type=ulong isUnsigned=true arg=30 result=[30] value inside of body: 16 out contract, type=ulong isUnsigned=true arg=16 result=[16] value inside of body: 32 out contract, type=ulong isUnsigned=true arg=32 result=[32] value inside of body: 0 out contract, type=uint isUnsigned=true arg=0 result=[0] value inside of body: 5 out contract, type=uint isUnsigned=true arg=5 result=[5] value inside of body: 2 out contract, type=uint isUnsigned=true arg=2 result=[2] value inside of body: 1 out contract, type=uint isUnsigned=true arg=1 result=[1] value inside of body: 10 out contract, type=ulong isUnsigned=true arg=10 result=[10] value inside of body: 30 out contract, type=ulong isUnsigned=true arg=30 result=[30] value inside of body: 2 out contract, type=uint isUnsigned=true arg=2 result=[2] value inside of body: 3 out contract, type=ulong isUnsigned=true arg=3 result=[3] value inside of body: 30 out contract, type=ulong isUnsigned=true arg=30 result=[30] value inside of body: 1 // argument=1 out contract, type=ulong isUnsigned=true arg=1 result=[1] // also successful result value inside of body: 30 out contract, type=ulong isUnsigned=true arg=30 result=[30] value inside of body: 3 out contract, type=ulong isUnsigned=true arg=3 result=[3] value inside of body: 30 out contract, type=ulong isUnsigned=true arg=30 result=[30] value inside of body: 18446744073709551615 // WTF???!!! out contract, type=ulong isUnsigned=true arg=1 result=[255, 255, 255, 255, 255, 255, 255, 255, 255, 1] // unsuccessful packing with previously many times used arg=1 core.exception.AssertError@compression.pb_encoding(105): Assertion failure ./main(_d_assertm+0x16) [0x81b4316] ./main() [0x8179d47] ./main(ubyte[] compression.pb_encoding.packVarint!(ulong).packVarint(ulong)+0x149) [0x8179899] ./main(ubyte[] compression.pb_encoding.packVarint!(long).packVarint(inout(long))+0x18) [0x81796a8]
Re: I cannot understand problem with argument of the function
(question is not about function body realisation - body just don't receives right argument value)
this(T...) not called in struct constructor
This may have been discussed before, but I'm not sure whether this is a bug or not. In any case it's a bit confusing. struct Foo2{ this(T...)(T args){ assert(0); } } void main(){ auto a2=Foo2();//doesn't call assert(0) (ie this(T...) not called) }