On Saturday, 14 October 2017 at 17:17:41 UTC, Petar Kirov
[ZombineDev] wrote:
Why not simply add extern (C) wrappers for your D code? I see
no point of using C, unless you want to be portable to arcane
architectures.
With this approach you'll have both the portability of C and
the advantages of
On Saturday, 14 October 2017 at 14:51:12 UTC, Adam D. Ruppe wrote:
My terminal.d works with most that stuff.
Yes I did look into existing solutions. Mainly my desire was not
to work in D alone but something available at command line and as
a library for shell-scripts and other languages too.
Hello. I prepared a utility/library to output ANSI escape codes
for terminal text attributes with capabilities as advertised at
https://sites.google.com/site/jamadagni/files/temp/textattr-usage.html. (AFAIK this set of capabilities does not exist already in any existing package.)
This was first
Adam D. Ruppe wrote:
> Look down to
> where it handles tuples (AliasSeq is the user-visible name for
> what the compiler internally calls a tuple).
Ouch. So even if the terminology gets abolished from Phobos, it's still
lurking in the compiler?
> Slicing a tuple creates a new tuple that refer
http://dlang.org/spec/template.html#TemplateTupleParameter
Apart from the obvious need for changing the references to tuples to alias
sequences (for which I'm working on a PR), my question:
Both the above page and http://dlang.org/phobos/std_meta.html refer to
"slicing" alias sequences. In D sl
Mike Parker wrote:
> Consider what would happen if they did not evaluate expressions:
I never said they should not evaluate expressions. Expressions are always
evaluated in any context in D, but they are immediately converted to values
(so long as they are evaluable). But for this very reason,
cym13 wrote:
> So, no, it's not a Voldemort type, it's exactly what the compiler
> tells you it is: the sequence of types (int, double).
Hmmm it seems to me that if it's not a runtime-valid type, then typeof()
shouldn't work at all...
--
Shriramana Sharma, Penguin #395953
cym13 wrote:
> This is great, but please post them
> preferably in then Learn section of the forum where you will get
> more help, the General section is more for discussing the
> evolution of D itself.
Yes I understand that, but earlier when I asked questions on D.learn about
advanced topics li
cym13 wrote:
> It could be useful combined with mixins to preprocess the code
> you write before compiling it.
Huh? Can you give me a concrete example? I'm not being intentionally dense
but I can't imagine such a use case where you can't just write the string
literal yourself...
--
Shriramana
Mike Parker wrote:
> All values, 3 and false included, *are* expressions. They are
> expressions with one operand and no operator, but they are still
> expressions.
>
> https://en.wikipedia.org/wiki/Value_(computer_science)
That's true, but the fact remains that the AliasSeq stores only the
res
Hello. By executing the following:
alias AS = AliasSeq!(int, double);
int foo(AS td) // same as int foo(int, double);
{
writeln(typeof(td).stringof);
return td[0] + cast(int)td[1];
}
I get:
(int, double)
But it is not very clear as to what exactly the type of `td` is! I
understand tha
D currently supports:
writeln((1 + 2).stringof);
to print:
1 + 2
What is the real-world use case of this "feature"? I mean, everyone knows
what the code they write looks like, so why would they want to have a
language feature to get a string representation of it that they can print
out to th
This is w.r.t. http://dlang.org/phobos/std_traits.html#isExpressions:
I am trying the following code:
import std.stdio, std.meta, std.traits;
void main()
{
alias a = AliasSeq!(1 + 2, "foo" == "goo");
if (isExpressions!a) write("This AliasSeq contains expressions: ");
foreach (v; a) {
Another twist to this is that the tuple created by .tupleof doesn't really
seem to be a new object of type Tuple!() but rather a "view" of sorts onto
the original object itself in the form of a tuple, else the example provided
at http://dlang.org/spec/class.html i.e.:
class Foo { int x; long y;
ZombineDev wrote:
>>struct Foo { int val; string name; }
>>Foo foo = {1, "one"};
>>auto t = foo.tupleof;
>>
>> Trying to use `alias` i.o. `auto` above fails.
>>
>> Now IIUC, trying to take the address of t fails, so it's still
>
> auto can refer only to run-time values.
>
> foo is run-time value
ZombineDev wrote:
> In short, the current D terminology calls:
> compile-time lists -> AliasSeq
> (http://dlang.org/phobos/std_meta#AliasSeq)
> run-time values of type lists -> Tuple
> (http://dlang.org/phobos/std_typecons#.Tuple)
Excellent explanation. I keep looking for a "Like" or "Upvote" but
Given that TypeTuple is replaced by AliasSeq (though many don't like the new
name), it seems that .tupleof should be replaced by .fieldvalues like
std.traits is proposed to have FieldIdentifiers and FieldTypes in
https://github.com/D-Programming-Language/phobos/pull/3756. Thoughts?
--
Shrirama
Hello. I just found that the following code compiles without any problem:
struct Foo { int val; string name; }
Foo foo = {1, "one"};
auto t = foo.tupleof;
Trying to use `alias` i.o. `auto` above fails.
Now IIUC, trying to take the address of t fails, so it's still a compile-
time-onl
https://en.wikipedia.org/wiki/IEEE_floating_point#Roundings_to_nearest says
that IEEE 754 provides two options for rounding to nearest: ties to even and
ties away from zero.
However, under
https://github.com/D-Programming-Language/phobos/blob/master/std/math.d#L4539
we have only one roundToNe
The enum members of FloatingPointControl are not documented individually at
http://dlang.org/phobos/std_math.html and I would like to submit a PR for
that. In connection with this, a few queries:
I note that there are already a few sparse ddoc comments such as at:
https://github.com/D-Programmi
Hello. From http://dlang.org/expression.html#OrOrExpression and the
subsequent AndAndExpression section it is clear to me that D does indeed
employ short-circuit evaluation true to being part of the C family.
But I am disappointed to note that D is not mentioned at
https://en.wikipedia.org/wiki
Shriramana Sharma wrote:
> Should I file a bug? Please advise.
Since there was no response, I filed:
https://issues.dlang.org/show_bug.cgi?id=15248
--
Shriramana Sharma, Penguin #395953
Forwarding a thread from the D.learn forum:
Shriramana Sharma wrote:
> import std.math;
> real round(real val, int prec)
> {
> real pow = 10 ^^ prec;
> return round(val * pow) / pow;
> }
>
> Trying to compile this I get:
>
> foo.d(5): Error: function foo.round (real val, int prec) is no
I tried:
import std.stdio;
void main()
{
int [5] vals = [1, 2, 3, 4, 5];
writefln("A = %d, B = %d, C = %d, D = %d, E = %d", vals []);
}
but got thrown an exception that "%d is not a valid specifier for a range".
The Python equivalent to flatten a list works:
vals = [1, 2, 3, 4,
John Colvin wrote:
> for better or worse, it's in std.traits so they
> don't have to.
Heh, I thought the library was supposed to provide what the basic language
itself doesn't provide...
--
Shriramana Sharma, Penguin #395953
Shriramana Sharma wrote:
> iterating through a
> string as a range will produce each semantically meaningful Unicode
> character rather than each UTF-8 or UTF-16 codepoint, it does make sense
> to do this.
Dear me... I meant UTF-8 encoded byte, rather than "codepoint", since all
characters have
Marc Schütz wrote:
>> BTW "isExpressions" – what kind of singular/plural grammar is
>> that?
>
> That's because it refers to the first argument, which is one
> symbol, not multiple ones. "consistsOfExpression" would probably
> be nicer, but - meh...
No it doesn't refer to the first argument. The
John Colvin wrote:
> It might be better to ask in http://forum.dlang.org/group/learn
> first for these sort of questions.
I didn't do that only because it concerns implemental details of Phobos
which didn't seem to be learner material. I have just now separately posted
an actual "I don't know w
John Colvin wrote:
>> But this is false, no? Since ElementType!string is char and not
>> dchar?
>
> No. char[], wchar[] and dchar[] all have ElementType dchar.
> Strings are special for ranges. It's a bad mistake, but it is
> what it is and apparently won't be changed.
Why is it a mistake? That
The templates `MutableOf` etc in std.traits – they don't seem to be of any
public use since `const(T)` is more direct and meaningful than `ConstOf!T`.
Except for `MutableOf` they are all currently public and even the `package`-
level `MutableOf` is publicly documented. All this seems pointless.
John Colvin wrote:
> static assert(is(ElementType!string == dchar));
But this is false, no? Since ElementType!string is char and not dchar?
> foreach(int i, dchar c; zip(ints, chars))
> or
> foreach(i, c; zip(ints, chars))
What's the diff betn char and dchar in this particular context?
--
Shr
In Python I can do:
ints = [1, 2, 3]
chars = ['a', 'b', 'c']
for i, c in zip(ints, chars):
print(i, c)
Output:
1 a
2 b
3 c
But in D if I try:
import std.stdio, std.range;
void main ()
{
int [] ints = [1, 2, 3];
char [] chars = ['a', 'b', 'c'];
foreach(int i, char c; zip(ints, c
deadalnix wrote:
> We should weed these out over time. Not really remove them, as to
> not break old code, but just create new names for these and
> remove old name from the doc and all.
Working on this right now...
BTW "isExpressions" – what kind of singular/plural grammar is that? When
renami
Since TypeTuple is now an alias of AliasSeq, I suppose it's OK to replace
all occurrences of TypeTuple in std.traits by AliasSeq?
--
Shriramana Sharma, Penguin #395953
Writing stdin.byLine(KeepTerminator.yes) is quite awkward. Why this long
name and not something shorter like KeepEOL?
BTW on Python the default is to *not* strip the newlines. Is there a reason
the opposite is true here?
--
Shriramana Sharma, Penguin #395953
Sönke Ludwig wrote:
> auto re = ctRegex!(`(?<=\d)(?=(\d\d\d)+\b)`, "g");
> foreach (line; stdin.byLine())
> {
> replaceAllInto(stdout.lockingTextWriter, line, re, ",");
> writeln();
> }
Another option is to use KeepTerminator.yes. Using writeln() is shorter! :-)
So this one does avoids all the e
Kagamin wrote:
> $ ls -v1 | sort
ls -v1 | sort -V
:-D
But there's still no good answer to the question why there should be a zero
in 2.068.2; OTOH, I discovered that since the API is still unstable, 2.068
should actually be 2.0.68.2 meaning 2nd bugfix release of the 68th minor
release of the
Jacob Carlborg wrote:
> If you declare the subclass as usual you can have a template mixin that
> adds the constructor.
>
> class SubException : Exception
> {
> mixin ExceptionConstructors;
> }
https://github.com/D-Programming-Language/druntime/pull/1413
--
Shriramana Sharma, Penguin #395953
Dmitry Olshansky wrote:
> I guess the idiomatic way is:
>
> foreach (pos; iota(0, sink.data.length, 4).retro)
Mmm no that throws an assertion failure, since the guarantee of the regex is
only to insert commas before every third digit *from the end*, but doing
retro on an *ascending* iota fixes
Dmitry Olshansky wrote:
> Listing code that is not routinely tested on each build means someday it
> may become broken. Anyway just issue a pull request, we can figure out
> the details in github discussion.
Hmmm... AFAICS the *Into function is most useful when you don't know how
many items of i
Shriramana Sharma wrote:
> Major versions zero are often used to
> indicate that the API is not yet stable and minor versions don't guarantee
> API stability. Since that's true for Phobos, where we don't have a stable
> versioning system yet, the zero as the major version number (ignoring the
> la
bitwise wrote:
> Not sure what you're getting at either.
By `ls -v1` I was illustrating that directory listing utilities are capable
of sorting numbers meaningfully, so there is no need for leading zeroes for
*that* purpose...
--
Shriramana Sharma, Penguin #395953
Shriramana Sharma wrote:
> I always wondered why DMD releases have a 0 in their minor version number
> -- surely 2.068 is the same as 2.68? Why then retain the zero?
BTW the Deb packages show the zero as a separate field in the SO versioning:
/usr/lib/x86_64-linux-gnu/libphobos2.so.0.68.2
/usr/l
bitwise wrote:
> touch f1.098
> touch f1.099
> touch f1.1.0
> touch f1.1.1
> ls
Sorry don't understand what you are getting at...
--
Shriramana Sharma, Penguin #395953
Marc Schütz wrote:
> Sorting happens in many places where the sorting program is not
> aware that it's working with version numbers. Think of directory
> listings, for example.
$ cd /tmp/
$ touch f{1..20}
$ ls -v1
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
f11
f12
f13
f14
f15
f16
f17
f18
f19
f20
--
Shriram
Dmitry Olshansky wrote:
> My problem with it is writeln/byLine b/c it can't be unittested.
> Documented unit-tests as examples are gold.
That's true, but then the point was not to produce a valid unittest for the
*Into functions but a meaningful *example*, which will make clear to a user
how th
Marc Schütz wrote:
> void main() {
> import std.conv;
> assert("1f".to!int(16) == 31);
> }
Hey thanks. In case the library maintainer wants to tighten up the unittest
for this, I wrote up a short Python to produce a unittest for this, since
Python also has the same support.
#! /usr/bin/env pyt
Marc Schütz wrote:
> Yes, it's still linked statically by default, at least with DMD.
> I don't know why this wasn't changed yet, I just tried linking
> against libphobos.so and it worked. The resulting binary is then
> down to 13 Kb, after stripping.
Filed https://issues.dlang.org/show_bug.cgi?i
Marc Schütz wrote:
> Yes, it's still linked statically by default, at least with DMD.
> I don't know why this wasn't changed yet, I just tried linking
> against libphobos.so and it worked. The resulting binary is then
> down to 13 Kb, after stripping.
Wow that's nice to hear! Can you outline the
Hello. I thought D did not prove the Python facility of being able to handle
bases 2 to 36 in string to integer conversion on request (there it is
int(num, base = )), but came upon this toImpl overload:
http://dlang.org/phobos/std_conv.html#.toImpl.5
which provides for a radix to be input. Ther
Jonathan M Davis wrote:
> It takes barely more time to add a bug to bugzilla than it does
> to post in the newsgroup about it
To my pleasant surprise, I found you were right! :-)
https://issues.dlang.org/show_bug.cgi?id=15216
--
Shriramana Sharma, Penguin #395953
Dmitry Olshansky wrote:
> Feel free to improve on the examples, I'd gladly pull such patches.
How about this, using the "comifying" regex from the replaceAll example:
auto re = ctRegex!(`(?<=\d)(?=(\d\d\d)+\b)`, "g");
auto sink = appender!(char [])();
foreach (line; stdin.byLine())
I went back to see my first post here in the D world two years ago:
http://forum.dlang.org/post/mailman.413.1369930723.13711.digitalmars-d-le...@puremagic.com
I had noted then with surprise that the most basic Hello World program took
300K+ with rdmd, but now it seems it's much more i.e. 600K+ w
Iain Buclaw via Digitalmars-d wrote:
>> I previously had some serious problems with GDC so never tried that ever
>> again, but dmd, ldmd2 and ldc2 all generally have the same syntax, esp.
>> w.r.t missing -o...
>>
>>
> Where's the bug report?
http://forum.dlang.org/post/mailman.572.1370073456.137
If a module's function throws an exception, shouldn't that module publicly
import that exception? Please observe:
$ cat errnoexception.d
import std.stdio;
//import std.exception;
void main()
{
File file;
try file = File("/non-existent-file");
catch (ErrnoException e) {}
}
$ dmd errno
bitwise wrote:
> 2.100 -> transition here, maintain sortability
Again, what's this about sortability? Raise your hands please whoever is
using strcmp or the like to do sorting on D version numbers!
--
Shriramana Sharma, Penguin #395953
Jacob Carlborg wrote:
> On 2015-10-15 20:07, Shriramana Sharma wrote:
>
>> $ cat myexception.d
>> string ExceptionDeclaration(string newExceptionName, string
>> baseExceptionName = "Exception")
>> {
>> return "class " ~ newExceptionName ~ ": " ~ baseExceptionName ~ `{
>> this(string
Iain Buclaw via Digitalmars-d wrote:
>> I previously had some serious problems with GDC so never tried that ever
>> again, but dmd, ldmd2 and ldc2 all generally have the same syntax, esp.
>> w.r.t missing -o...
>>
>>
> Where's the bug report?
Sorry I don't think I filed one. It was quite some tim
H. S. Teoh via Digitalmars-d wrote:
> Windows doesn't follow any of the proposed versioning schemes (I mean,
> what's up with 3.0 -> 3.1 -> 95 -> 98 -> 2000 -> XP -> 7 -> 8 -> 9... ?
Heh -- nice point. But they market the visuals and the interface, not the
version numbers. Nevertheless, lots of
Dmitry Olshansky wrote:
> No. Conceptually replace does replaceInto but creates a new appender
> each time. This is the overhead replaceInto means to avoid.
That's much clear now, thanks!
--
Shriramana Sharma, Penguin #395953
I always wondered why DMD releases have a 0 in their minor version number --
surely 2.068 is the same as 2.68? Why then retain the zero?
--
Shriramana Sharma, Penguin #395953
Daniel Kozak wrote:
> dmd, gdmd, ldmd2
Excuse me -- I don't understand what you mean. I was asking if anyone had
written a shell wrapper for dmd to accept standard GCC/Clang-like syntax for
input files etc. I am particularly missing the -o option.
No big deal, guess can do it myself...
I prev
dmd's command-line argument parsing is different from that of gcc/clang. Of
course I can use ldc or gdc but as I want to stay with latest improvements I
would prefer to use dmd, but I'm having to readapt my habit every time I
want to compile a D program. Has anyone written a thin shell wrapper
ref int foo(ref int x) { return x ; }
void main ()
{
foo(3) ;
// Error: function rvalue_argument.foo (ref int x) is not callable using
argument types (int)
// Comment: "argument ref int x of function rvalue_argument.foo cannot bind
to an rvalue" would be clearer IMO
int i ;
ref ir =
Hello. The doc on std.regex.replace{First,All}Into reads:
A variation on replaceAll that instead of allocating a new string on
each call outputs the result piece-wise to the sink. In particular this
enables efficient construction of a final output incrementally.
Example:
//swap all
Jonathan M Davis wrote:
> On Thursday, 15 October 2015 at 18:07:24 UTC, Shriramana Sharma
> wrote:
>> So, any thoughts? Any way this could be improved? Would be nice
>> if that mixin got into the standard library somehow...
>
> Writing a mixin to create a standard constructor for exception
> type
object.d (from dmd 2.068.2) line 1636:
auto e = new Exception("msg", new Exception("It's an Excepton!"), "hello",
42);
Next time somebody edits this file, s/Excepton/Exception.
Didn't want to file a bug for such a minor issue.
In Python I can create my own thin exceptions (i.e. just different type for
convenience of identification in a catch block, no added functionality) by:
class MyError(ExceptionBaseClass): pass
Even in C++ I can do just:
struct MyException: public std::exception {};
But in D:
$ cat except.d
cla
Once the front end of DMD becomes fully D, I read that the backend
will also become D, but then what will happen to GDC and LDC whose
backends are C++ IIUC?
--
Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा
Just now saw Walter's tentative roadmap going forward to 2.69 etc...
I don't see anything mentioned about the promised C++ interface. Was I
mistaken in thinking that it is part of 2.68? Please can anyone in the
know have mercy on us lesser souls and update
http://dlang.org/cpp_interface.html in ac
Trying to compile the attached program to test DMD 2.068's promised
C++ interfacing capabilities:
$ dmd qt.d -L-L/usr/share/x86_64-linux-gnu -L-lQt5Core -L-lQt5Gui
qt.o:(.rodata+0x40): undefined reference to `QWidget::show()'
qt.o: In function `_Dmain':
qt.d:(.text._Dmain+0x3b): undefined referenc
I wonder if it is me or everyone is receiving some sort of
kitchen-related spam via the mailing list? The email ID or keywords
they are using seem to be relatively predictable and unrelated to
programming so I wonder whether the listadmin hasn't had the time to
kick out this intruder?
--
Shrirama
On Wednesday, November 5, 2014, Craig Dillabaugh via Digitalmars-d <
digitalmars-d@puremagic.com
> wrote:
> This is my second Call for Proposals for the 2015 Google Summer of Code.
> Anyone interested in mentoring, or who has good idea's for a project for
> 2015 please post here.
Um sorry if I'm
On 11/4/14, Daniel Murphy via Digitalmars-d wrote:
>> Now from the http://dlang.org/cpp_interface I find out the current
>> status of built-in C++ interfacing support. I'm working on Linux so
>> using the COM support is not an option for me (whatever COM may be!).
>
> That page is out of date. Su
On Mon, Nov 3, 2014 at 3:42 PM, bearophile via Digitalmars-d
wrote:
>
> There's also a third option, offer the information I have, if it's valuable,
> even when it's not complete because others can get interested and find the
> full information themselves
That's true. But when making points to hi
Hello people. FWIW, for those who want to alias one symbol to multiple
other symbols and saying that only the old syntax helps them, how
about allowing alias a = b = c = int? It is merely an extension of the
assignment-based new syntax, no?
--
Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा
I wonder if posting this message to this list is more appropriate than
to d.learn?
-- Forwarded message --
In the following pages (which have differing file naming patterns for
whatever reason!):
http://dlang.org/interfaceToC.html
http://dlang.org/cpp_interface
I would suggest to
It was recommended that I discuss this on this list rather than
d.learn... (I didn't think I'd graduate out of d.learn *that*
quickly...)
-- Forwarded message --
Hello. I really really need to be able to interface well with a C++
library which contains lots of classes if I am goin
Hello. At http://dlang.org/spec.html I read: "This is also
available as a PDF document" where "PDF document" is a link to
http://dlang.org/dlangspec.pdf. However, the PDF is just as 4
page doc with only the TOC. The individual pages don't seem to
have PDFs either. I hope this is not intentional.
79 matches
Mail list logo