H. S. Teoh wrote:
If this was code generated by an external utility
I wasn't argumenting for using external utilities, but against the
argument, that separating code for separatable phases would obfuscate
the code.
for more than one _needed_ phase
compile-time validation of generated code
On 02/04/2012 08:51 PM, Era Scarecrow wrote:
If I'm reading how pure works, my original example was likely broken as
it was part of a struct that returned a state value (although the
contract constraints meaning was still valid).
So is pure fully usable or is it not yet ready? Makes me think
On 02/04/12 02:03, Timon Gehr wrote:
On 02/03/2012 11:08 AM, Artur Skawina wrote:
On 02/03/12 00:20, Jonathan M Davis wrote:
in is pointless on value types. All it does is make the function parameter
const, which really doesn't do much for you, and in some instances, is
really
annoying.
On Sat, 04 Feb 2012 15:04:50 +0100, Vidar Wahlberg cani...@exent.net
wrote:
This code does not compile:
Bar.d:6: Error: function expected before (), not module Struct of type
void
Bar.d:6: Error: constructor Foo.Foo.this (Struct s) is not callable
using argument types (_error_)
Why is
F i L:
Why/where should I use contracts vs debug statements?
This is a sting point:
http://en.wikipedia.org/wiki/Design_by_contract
Contract-based programming is a different way to write programs. But adding few
more asserts here and there is useful still.
int foo(int bar)
{
Timon Gehr wrote:
First of all, you don't really need the debug statements,
assertions are stripped from -release'd code anyway.
The assertions in the function body are not part of the
function interface. (eventually, contracts can be on function
declarations lacking a function body)
On Sat, 04 Feb 2012 18:18:22 +0100, F i L witte2...@gmail.com wrote:
Why/where should I use contracts vs debug statements? Is it completely
arbitrary? If so, I wonder if contracts syntax is even needed:
int foo(int bar)
in
{
assert(bar != 0);
}
body
{
On 02/04/2012 06:18 PM, F i L wrote:
Why/where should I use contracts vs debug statements? Is it completely
arbitrary? If so, I wonder if contracts syntax is even needed:
int foo(int bar)
in
{
assert(bar != 0);
}
body
{
return bar + 1;
}
The thing I like more about debug statements, is that I
If I'm reading how pure works, my original example was likely
broken as it was part of a struct that returned a state value
(although the contract constraints meaning was still valid).
So is pure fully usable or is it not yet ready? Makes me think
that pure should have further
So why not just use classes? I've understood it as there may be a
performance gain by using structs over classes, and in my program Point
and Coordinate are used heavily.
The other big difference is value vs. reference type.
You can use alias this to achieve something like struct
Good day.
I know inheritance is a misleading word as there's no such thing when
it comes to structs, but I couldn't think of a better description for
this problem:
Let's say I got a struct for a location on a 2-dimensional plane:
struct Point {
int x;
int y;
}
Further I also need to
On Sat, 04 Feb 2012 12:38:30 +0100, Vidar Wahlberg cani...@exent.net
wrote:
Good day.
I know inheritance is a misleading word as there's no such thing when
it comes to structs, but I couldn't think of a better description for
this problem:
Let's say I got a struct for a location on a
On 2012-02-04 13:06, Simen Kjærås wrote:
It seems that what you want is alias this:
Thank you both, that's exactly what I needed.
Leeching a bit more on the thread:
Going back to the method:
int somethingNifty(Point p) {
return p.x + p.y;
}
Let's say I have the following code:
for (x; 0 ..
Vidar Wahlberg:
Leeching a bit more on the thread:
Going back to the method:
int somethingNifty(Point p) {
return p.x + p.y;
}
Let's say I have the following code:
for (x; 0 .. 10) {
for (y; 0 .. 10) {
Point p = {x, y};
somethingNifty(p);
}
}
[How] can you
On Sat, 04 Feb 2012 13:55:55 +0100, Vidar Wahlberg cani...@exent.net
wrote:
On 2012-02-04 13:06, Simen Kjærås wrote:
It seems that what you want is alias this:
Thank you both, that's exactly what I needed.
Leeching a bit more on the thread:
Going back to the method:
int
On 2012-02-04 14:45, Simen Kjærås wrote:
Like bearophile said, Point(x, y) should work - assuming you have
defined no other constructors for Point.
You are correct, my apologies for not testing more thoroughly.
Let me try again, explaining the real issue:
I have 3 files:
-- Bar.d --
import
On Thursday, 2 February 2012 at 19:40:14 UTC, Stewart Gordon
wrote:
Under Windows, you can use a stringtable resource. It's
possible to make resources language-specific, but I don't know
how.
With LANGUAGE statement?
Also
http://msdn.microsoft.com/en-us/library/windows/desktop/aa381050%28v=vs.85%29.aspx
You can't write this:
import std.algorithm;
void main() {
int[] a1 = [1, 2, 3];
auto r1 = map!(x = 2 * x)(a1);
auto r2 = map!(x = x ^^ 2)(a1);
auto a2 = [r1, r2];
}
because the types of r1 and r2 aren't compatibile:
test.d(6): Error: incompatible types for ((r1) ? (r2)):
On 02/04/2012 03:38 AM, Vidar Wahlberg wrote:
Let's say I got a struct for a location on a 2-dimensional plane:
struct Point {
int x;
int y;
}
Further I also need to represent a location in a 3-dimensional space:
struct Coordinate {
int x;
int y;
int z;
}
If these were classes
On 02/04/2012 08:25 AM, Ali Çehreli wrote:
The following templatizes the coordinate types, but you could use put
write everywhere:
That should be ... you could write *ints* everywhere.
Ali
Ali:
It already exists: inputRangeObject() supports the accessing ranges
and outputRangeObject takes care of output ranges.
Thank you, I did miss them :-)
Bye,
bearophile
Why/where should I use contracts vs debug statements? Is it
completely arbitrary? If so, I wonder if contracts syntax is even
needed:
int foo(int bar)
in
{
assert(bar != 0);
}
body
{
return bar + 1;
}
The thing I like more about debug statements, is that I
hi,
What should do a D lint?
- check if in code the are no mixin between space / tab for indent
- check indent (4 spaces as default)
complete the list
On 02/04/2012 06:55 PM, Artur Skawina wrote:
On 02/04/12 02:03, Timon Gehr wrote:
On 02/03/2012 11:08 AM, Artur Skawina wrote:
On 02/03/12 00:20, Jonathan M Davis wrote:
in is pointless on value types. All it does is make the function parameter
const, which really doesn't do much for you, and
Pure does not imply const in D. If you want stronger
guarantees, just turn 'test' into a const (or immutable) member
function. In D, a function can change anything that is mutable
and reachable through its parameters, this includes the
implicit 'this' pointer. The reason for this design is
On 02/04/12 22:20, Timon Gehr wrote:
On 02/04/2012 06:55 PM, Artur Skawina wrote:
On 02/04/12 02:03, Timon Gehr wrote:
On 02/03/2012 11:08 AM, Artur Skawina wrote:
On 02/03/12 00:20, Jonathan M Davis wrote:
in is pointless on value types. All it does is make the function parameter
const,
On 02/04/2012 11:04 PM, Era Scarecrow wrote:
Pure does not imply const in D. If you want stronger guarantees, just
turn 'test' into a const (or immutable) member function. In D, a
function can change anything that is mutable and reachable through its
parameters, this includes the implicit 'this'
Hi,
I'm trying to use a raw socket, but when I create a
socket(AddressFamily.INET, SocketType.RAW, ProtocolType.TCP) and then
I use socket.sendTo(datagram, addr) I've got a 10002 code error
Invalid argument...
Can anyone help me please, and sorry for my bad english :s
On 02/04/2012 11:23 PM, Artur Skawina wrote:
On 02/04/12 22:20, Timon Gehr wrote:
On 02/04/2012 06:55 PM, Artur Skawina wrote:
On 02/04/12 02:03, Timon Gehr wrote:
On 02/03/2012 11:08 AM, Artur Skawina wrote:
On 02/03/12 00:20, Jonathan M Davis wrote:
in is pointless on value types. All it
Probably the restriction was lifted after TDPL was out.
Yes. The compiler will only reorder/run in parallel/optimize if
it is safe (not changing execution semantics). Pure can be used
to prove that certain optimizations are safe. If a pure
function only takes const or immutable arguments,
On 02/04/12 23:44, Timon Gehr wrote:
On 02/04/2012 11:23 PM, Artur Skawina wrote:
On 02/04/12 22:20, Timon Gehr wrote:
On 02/04/2012 06:55 PM, Artur Skawina wrote:
Semi-related quiz:
immutable(char)[] a = a;
const(char)[] b = b;
auto aa = a ~ a;
auto bb = b ~ b;
On 02/05/2012 12:15 AM, Era Scarecrow wrote:
Probably the restriction was lifted after TDPL was out.
Yes. The compiler will only reorder/run in parallel/optimize if it is
safe (not changing execution semantics). Pure can be used to prove
that certain optimizations are safe. If a pure
On 02/04/12 07:46, H. S. Teoh wrote:
On Fri, Feb 03, 2012 at 10:18:18PM -0800, H. S. Teoh wrote:
Why does the following code give a compiler error?
static int[string] table = [abc:1, def:2, ghi:3];
Error message is:
prog.d:3: Error: non-constant expression [abc:1,def:2,ghi:3]
On 2/4/12 11:42 PM, Eyyub wrote:
I'm trying to use a raw socket, […]
Use SocketType.STREAM if you want TCP. SOCK_RAW is for cases where you
want a raw IP socket (for the exact details, look it up in your OS docs).
David
the signature I meant looks like
pure int squaredPlus(int)immutable;
Which then the only way you could call it, was if the object
itself was immutable, which is definitely safe (I think). Hmmm...
On 02/05/2012 01:20 AM, Era Scarecrow wrote:
the signature I meant looks like
pure int squaredPlus(int)immutable;
Which then the only way you could call it, was if the object itself was
immutable, which is definitely safe (I think). Hmmm...
Alternatively you can use pure int
On Thu, Feb 2, 2012 at 4:48 PM, xancorreu xancor...@gmail.com wrote:
Hi,
Is there any way for localizate and internationalizate messages?
I were shocked if D has something like Fantom
[http://fantom.org/doc/docLang/Localization.html]. Gettext is pretty ugly
;-)
I just glanced at Fantom
38 matches
Mail list logo