On Sunday, 18 March 2018 at 18:45:23 UTC, Steven Schveighoffer
wrote:
If we could go back in time and talk with a young Walter about
the consequences of choosing the scheme the way it is, maybe he
might have made different choices, but at this point, it's hard
to change it.
I think this
On Sunday, 18 March 2018 at 11:12:46 UTC, Alex wrote:
´´´
Are there any scenarios in which the person writing the class,
would want to encapsulate their class, or some parts of it,
from the rest of a module (while being forced to put the class
in this module)?
´´´
The answer is no. As the
On Sunday, 18 March 2018 at 10:14:30 UTC, Alain Soap wrote:
BTW i think adding this can be useful. The FreePascal language
has `strict private` for example.
" Private - All fields and methods that are in a private block,
can only be accessed in the module (i.e. unit) that contains the
class
On Sunday, 18 March 2018 at 05:01:39 UTC, Amorphorious wrote:
The fact is, the creator of the class is also the creator of
the module.. and preventing him from having full access to the
class is ignorant. He doesn't need to encapsulate himself.
Encapsulation is ONLY meant to reduce
On Sunday, 18 March 2018 at 05:01:39 UTC, Amorphorious wrote:
Why do you insist that you know how everything works and you
are the harbinger of truth. The fact is, you don't know squat
about what you are talking about and you just want to conform D
to your naive ignorant
On Saturday, 17 March 2018 at 21:33:01 UTC, Adam D. Ruppe wrote:
On Saturday, 17 March 2018 at 21:22:44 UTC, arturg wrote:
maybe extend that to a list of types?
this is basically what C++ friend does and D was trying to
avoid the complexity of
Really, the complexity of 'friend' comes from
On Saturday, 17 March 2018 at 14:16:19 UTC, bauss wrote:
I don't like the name @deny .
how about:
@reallyis private string firstName_;
mmm..perhaps not... then how about...
@strictly private string firstName_;
On Saturday, 17 March 2018 at 09:18:13 UTC, Nick Treleaven wrote:
It's a language design decision as to whether a particular
feature is worth supporting. I would like this feature too
though. I'm not sure how much compiler complexity would be
added by having another visibility modifier.
D
On Tuesday, 13 March 2018 at 21:38:59 UTC, Amorphorious wrote:
You are a moron...etc..etc..etc..etc.
See. This is what happens when you have access to a keyboard
while high on ice.
On Tuesday, 13 March 2018 at 08:44:48 UTC, Mike Parker wrote:
Making modules the lowest level of encapsulation does that
without the need for an extra keyword for friends while still
maintaining a strict border between external and internal APIs.
Moreover, it restricts friends to the same
On Tuesday, 13 March 2018 at 12:10:07 UTC, rikki cattermole wrote:
On 14/03/2018 1:02 AM, psychoticRabbit wrote:
On Tuesday, 13 March 2018 at 11:31:12 UTC, rikki cattermole
wrote:
Ah yes.
You're completely correct if you subscribe to Adam's and
ketmar's file sizes expectation.
A D module
On Tuesday, 13 March 2018 at 11:31:12 UTC, rikki cattermole wrote:
Ah yes.
You're completely correct if you subscribe to Adam's and
ketmar's file sizes expectation.
A D module and package is one level of abstraction. If that
level of abstraction starts to fill up and gets large, you
split
On Tuesday, 13 March 2018 at 08:44:48 UTC, Mike Parker wrote:
Moreover, it restricts friends to the same module, easing the
maintenance burden and decreasing the chance of error. It was a
great decision.
But, a module can contain so many 'friends'.
Q. How many 'friends' does it take, before
On Tuesday, 13 March 2018 at 08:29:42 UTC, Alex wrote:
package myPackage;
public class Main {
public static void main(String[] args)
{
System.out.println("Hello World!");
myClass c = new myClass();
c.myPrivateClassMember= "wtf";
On Tuesday, 13 March 2018 at 09:52:06 UTC, Mike Parker wrote:
On Tuesday, 13 March 2018 at 09:14:26 UTC, psychoticRabbit
wrote:
That's make a little uncomfortable, given how long and complex
modules can easily become(and aleady are)
Is there a practical difference between a) a module that
On Tuesday, 13 March 2018 at 08:44:48 UTC, Mike Parker wrote:
Any new keywords, or reuse of existing keywords, does make the
language more complex. Everything that is added must have a
reason. Private is module level because friend is so common in
C++, i.e. people find it useful and it would
On Tuesday, 13 March 2018 at 08:05:43 UTC, psychoticRabbit wrote:
On Tuesday, 13 March 2018 at 06:03:11 UTC, Mike Parker wrote:
I think it's a great feature and I use it frequently. It's
allows more flexibility in class design. Without it, we'd need
another protection attribute to enable the
On Tuesday, 13 March 2018 at 06:03:11 UTC, Mike Parker wrote:
I think it's a great feature and I use it frequently. It's
allows more flexibility in class design. Without it, we'd need
another protection attribute to enable the concept of "private
to the module".
what about a new access
On Tuesday, 13 March 2018 at 07:05:48 UTC, rikki cattermole wrote:
Your thought model is much younger than modules. Modules have
existed since the mid 70's.
They work, other designs over the years have proven to have
faults and problems.
D's design is evolved from already existing ideas to
On Tuesday, 13 March 2018 at 06:43:55 UTC, ketmar wrote:
that is, we should stick to defective design only 'cause there
is no "other D" that made it right? ;-)
also, your question is not valid. you were told several times
that you're evaluating the whole thing wrong, but you're
insisting
On Tuesday, 13 March 2018 at 06:03:11 UTC, Mike Parker wrote:
The same applies here. Encapsulation simply isn't broken by
this feature.
What you're saying, is in D, class encapsulation is really
'module' encapsulation.
I get it. Fine. It's an intersting design decision.
But, in doing
On Tuesday, 13 March 2018 at 06:26:13 UTC, Radu wrote:
On Tuesday, 13 March 2018 at 06:14:49 UTC, psychoticRabbit
wrote:
On Tuesday, 13 March 2018 at 06:01:43 UTC, ketmar wrote:
ah, yes, sorry: i completely forgot that C++ was invented
after c# and java. mea maxima culpa!
My point was,
On Tuesday, 13 March 2018 at 06:25:39 UTC, ketmar wrote:
psychoticRabbit wrote:
So the 3 most used languages got it wrong??
yes.
do you know any other language, where a private class memeber, is
not private to the class?
(btw. that's a question, not a statement).
On Tuesday, 13 March 2018 at 06:03:11 UTC, Mike Parker wrote:
I think it's a great feature and I use it frequently. It's
allows more flexibility in class design. Without it, we'd need
another protection attribute to enable the concept of "private
to the module".
That's kind of my point.
On Tuesday, 13 March 2018 at 05:35:30 UTC, Amorphorious wrote:
There is another problem:
3rd: You are a brainwashed monkey who can't think for himself.
Gee..takes some real brains to come up with that one.
See, You learned a little about C++/C#/Java and think the world
must conform to
On Tuesday, 13 March 2018 at 06:01:43 UTC, ketmar wrote:
ah, yes, sorry: i completely forgot that C++ was invented after
c# and java. mea maxima culpa!
My point was, that the 2 most widely used and popular languages
on the plant, C# and Java, decided NOT to make private, something
mean
On Tuesday, 13 March 2018 at 05:52:55 UTC, ketmar wrote:
psychoticRabbit wrote:
There are two problems I see:
1) it is not how C++ done it.
2) it is not how C++ done it.
and you're completely right: it is not how C++ done it.
umm...didn't you forget something:
1) it is not how C# done it.
On Tuesday, 13 March 2018 at 02:24:38 UTC, Mike Parker wrote:
On Tuesday, 13 March 2018 at 02:06:57 UTC, psychoticRabbit
wrote:
Mmm.. I don't think I like it.
I feel you should be able to make a member of a class,
private, regardless of where the class is located. This seems
to break the
On Tuesday, 13 March 2018 at 01:39:13 UTC, Jonathan M Davis wrote:
private is private to the module, not the class. There is no
way in D to restrict the rest of the module from accessing the
members of a class. This simplification makes it so that stuff
like C++'s friend are unnecessary. If
I cannot get my head around, why private is not private, in D.
How do I make a private member, private?
-
module test;
import std.stdio;
void main()
{
myClass c = new myClass();
c.myPrivateClassMember= "wtf";
writeln(c.myPrivateClassMember);
}
class myClass
{
private
On Sunday, 11 March 2018 at 03:52:19 UTC, psychoticRabbit wrote:
Whether dub does that currently I do not know, as i don't use
dub, or any additional packages outside of phobos.
oh > dub list ;-)
On Sunday, 11 March 2018 at 01:04:27 UTC, Roberto wrote:
How do I list installed modules?
or..
https://dlang.org/phobos/index.html
On Sunday, 11 March 2018 at 01:04:27 UTC, Roberto wrote:
How do I list installed modules?
dmd --list-modules
datefmt
dateparser
std.algorithm
std.array
std.conv
std.datetime
std.digest
std.exception
std.file
std.format
std.getopt
std.json
std.math
...
Presumably, you mean packages installed
On Monday, 5 March 2018 at 06:01:27 UTC, J-S Caux wrote:
So the codes are trivial, simply some check of raw speed:
double x = 0.0;
for (int a = 0; a < 10; ++a) x += atan(1.0/(1.0 +
sqrt(1.0 + a)));
for C++ and
double x = 0.0;
for (int a = 0; a < 1_000_000_000; ++a) x +=
On Monday, 5 March 2018 at 23:34:50 UTC, askjfbd wrote:
Someone please tell me how, for I am a newbie and don't know
any solutions even to this very simple problem. As I learned
dlang using the Dlang tour page, I stuck at the alias & Strings
page. I have tried to compile the following simple
On Friday, 2 March 2018 at 10:08:57 UTC, Simen Kjærås wrote:
This is of course only partly true.
while ((*dst++ = *src++) != 0) {}
works just great, and also better shows what's actually being
tested for in the loop.
--
Simen
That's what I was after. Thanks!
trying to do this C code, in D, but getting error:
"Error: assignment cannot be used as a condition, perhaps `==`
was meant?"
any help much appreciated:
--
while ((*dst++ = *src++)) {}
--
On Wednesday, 28 February 2018 at 01:06:30 UTC, dark777 wrote:
Regex validates years bisexto and not bisextos in format:
const std::regex
On Tuesday, 27 February 2018 at 00:04:59 UTC, H. S. Teoh wrote:
A 64-bit double can only hold about 14-15 decimal digits of
precision. Anything past that, and there's a chance your
"different" numbers are represented by exactly the same bits
and the computer can't tell the difference.
T
On Sunday, 25 February 2018 at 14:52:19 UTC, Steven Schveighoffer
wrote:
1 == 1.0, no?
no. at least, not when a language forces you to think in terms of
types.
1 is an int.
1.0 is a floating point.
I admit, I've never printed output without using format
specifiers, but still, if I say
On Sunday, 25 February 2018 at 12:13:31 UTC, Andrea Fontana wrote:
On Sunday, 25 February 2018 at 09:30:12 UTC, psychoticRabbit
wrote:
I would have preffered it defaulted java style ;-)
System.out.println(1.0); // i.e. it prints 'what I told it to
print'.
System.out.println(1.0); // print
On Sunday, 25 February 2018 at 08:46:19 UTC, rumbu wrote:
On Sunday, 25 February 2018 at 08:08:30 UTC, psychoticRabbit
wrote:
But umm what happended to the principle of least
astonishment?
writeln(1.1); (prints 1.1)
whereas..
writeln(1.0); (prints 1)
I don't get it. Cause it's
On Sunday, 25 February 2018 at 06:35:07 UTC, Jonathan M Davis
wrote:
It's not printing ints. It's printing doubles. It's just that
all of the doubles have nothing to the right of the decimal
point, so they don't get printed with a decimal point. If you
did something like start with 1.1, then
On Sunday, 25 February 2018 at 05:40:19 UTC, Jonathan M Davis
wrote:
int[] intArr = iota(1, 11).array();
- Jonathan M Davis
thanks!
oh man. It's so easy to do stuff in D ;-)
But this leads me to a new problem now.
When I run my code below, I get ints printed instead of doubles??
Hi. Anyone know whether something like this is possible?
I've tried various conversions/casts, but no luck yet.
Essentially, I want to cast the result set of the iota to an
array, during initialisation of the variable.
no, I don't want to use 'auto'. I want an array object ;-)
On Saturday, 24 February 2018 at 04:22:12 UTC, Jonathan M Davis
wrote:
Why is there anything dodgy going on and why would you need
contracts? Contracts actually tend to go very badly with
generic code, because whatever they assert has to be generic,
and while that works sometimes, more often
On Saturday, 24 February 2018 at 03:58:48 UTC, Jonathan M Davis
wrote:
Whether an implicit cast or an explicit cast makes more sense
depends entirely on what the code is doing, but either way, the
conversion needs to be forced inside the function, or you end
up with bugs. Far too often, when
On Saturday, 24 February 2018 at 03:43:25 UTC, Jonathan M Davis
wrote:
That does not do what the OP requested at all. That tests
whether T is one of byte, ubyte, short, ushort, int, uint,
long, and ulong, whereas what the OP wants is to test whether T
can be cast to int.
- Jonathan M Davis
On Saturday, 24 February 2018 at 03:30:45 UTC, psychoticRabbit
wrote:
On Saturday, 24 February 2018 at 02:54:13 UTC, Jonathan wrote:
I am having trouble finding many useful explanations of using
template constraints beyond basic usage.
I would like to have a template constrant to enforce that
On Saturday, 24 February 2018 at 02:54:13 UTC, Jonathan wrote:
I am having trouble finding many useful explanations of using
template constraints beyond basic usage.
I would like to have a template constrant to enforce that a
type can be explicitly cast to another type:
void (T)(T t)
On Saturday, 24 February 2018 at 02:54:13 UTC, Jonathan wrote:
I am having trouble finding many useful explanations of using
template constraints beyond basic usage.
I would like to have a template constrant to enforce that a
type can be explicitly cast to another type:
void (T)(T t)
On Wednesday, 21 February 2018 at 11:41:18 UTC, Diederik de Groot
wrote:
Removing the pragma(lib, "curl") seems to fix the issue on DFly
(and FreeBSD). Updated the pull request.
I guess pragma(lib, xxx) needs a little bit of attention to see
what causes it not to work.
something to do with
On Monday, 19 February 2018 at 12:01:31 UTC, Jonathan M Davis
wrote:
I've never been able to figure this problem out, so I've I
always just edited the makefile so that the two programs in
CURL_TOOLS aren't built. IIRC, if you use -v to see the full
linker command, it's even actually linking to
On Monday, 19 February 2018 at 12:01:31 UTC, Jonathan M Davis
wrote:
I've never been able to figure this problem out, so I've I
always just edited the makefile so that the two programs in
CURL_TOOLS aren't built. IIRC, if you use -v to see the full
linker command, it's even actually linking to
So I finally got around to building from source.
I have builds working just fine on a variety of linux machines,
it's just a FreeBSD problem I'm having.
So, on FreeBSD, I can build the dmd directory, and the phobos
directory ok.
When building tools directory, most tools get built ok, but
On Sunday, 18 February 2018 at 15:23:14 UTC, Cym13 wrote:
On Sunday, 18 February 2018 at 14:48:59 UTC, Cym13 wrote:
[...]
Just thought of a much better/simpler solution for that last
case that also doesn't force you to read all data (which might
be impossible when dealing with infinite
On Wednesday, 14 February 2018 at 15:24:42 UTC, Vino wrote:
...the only problem is i am not sure hot to get the out put
without the headings(Caption FreeSpace,Size) any help on same
is much appreciated.
writeln(result.output[38..$]);
On Wednesday, 14 February 2018 at 12:29:13 UTC, rikki cattermole
wrote:
See:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364935(v=vs.85).aspx
any idea on how I'd convert this C# code to D?
==
public class Program
{
[DllImport("kernel32.dll")]
On Tuesday, 13 February 2018 at 14:21:31 UTC, bauss wrote:
What you can do is use aliases to use both functions.
import io = std.stdio;
void main()
{
import file = std.file;
file.write("hello");
io.writeln("hello again");
}
that's a nice simple solution.
thanks.
On Tuesday, 13 February 2018 at 14:18:05 UTC, ketmar wrote:
psychoticRabbit wrote:
Also, if I do this below, how does the compiler choose the
correct write function?
import std.stdio;
import std.file;
void main()
{
write("hello");
writeln("hello again");
}
it's easy: just take a
On Tuesday, 13 February 2018 at 13:57:38 UTC, ketmar wrote:
`std.file` has function named `write()` too. and local import
completely shadows global imports (i.e. it removes global
imports from overload set for the given scope), hence
`std.stdio.write()` is not available there.
"..local
On Tuesday, 13 February 2018 at 13:52:37 UTC, rikki cattermole
wrote:
On 13/02/2018 1:46 PM, psychoticRabbit wrote:
So, strange problem below.
The commented-out line will not compile (if I un-comment it),
unless I either move std.stdio into main, or, move std.file
out of main.
Whereas
On Tuesday, 13 February 2018 at 13:46:11 UTC, psychoticRabbit
wrote:
So, strange problem below.
The commented-out line will not compile (if I un-comment it),
unless I either move std.stdio into main, or, move std.file out
of main.
Whereas writeln works just fine as is.
So, strange problem below.
The commented-out line will not compile (if I un-comment it),
unless I either move std.stdio into main, or, move std.file out
of main.
Whereas writeln works just fine as is.
-
module test;
import std.stdio;
void main()
{
import std.file;
On Tuesday, 13 February 2018 at 05:51:05 UTC, Domain wrote:
module main;
void main ()
{
writeln("Hello");
}
Of course, this won't compile, but error message is confused:
C:\Git\hello\source>dmd app.d
app.d(5): Error:
object.Error@(0): Access Violation
0x0065445A
On Sunday, 11 February 2018 at 01:13:00 UTC, psychoticRabbit
wrote:
Well, in C.. I can do:
int arr[2] = { [0]=10, [1]=20 };
I cannot work out how to do that in D yet (anyone know??)
Oh. just worked it out after reading this thread ;-)
int[2] arr = [ 0:10, 1:20 ];
On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote:
I have a large static initialized array, let's say int[155],
and I forgot to declare the last element:
int[155] myarray = [
a,
b,
c,
...
//forgot to declare the 155th element
];
Well, in C.. I can do:
int arr[2] = {
67 matches
Mail list logo