Hello,
I'm working on range adapters that should allow reading and writing
individual bits from/to other ranges. Right now for simplicity I only
allow that for ranges that have numerics as ElementType.
Making an input bitwise range is pretty straightforward: popFront on
original range is cal
Stanislav Blinov:
> What I'm stuck with is an output bitwise range. If the adapted output
> range works via mutable front/popFront mechanism, implementing bitwise
> output is almost identical to bitwise input. But when adapted range
> provides output interface via put() method, I have no possibl
06.09.2010 15:37, bearophile wrote:
I am not sure, but this looks related to the idea of "Vectorized Lazines" that
I have shown time ago (from MonetDB/X100), and that later has partially appeared in the
Clojure language as Chunked Sequences:
http://digitalmars.com/d/archives/digitalmars/D/Re_
On 09/04/2010 02:11 PM, Simen kjaeraas wrote:
Peter Alexander wrote:
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic
wrote:
> What does char[1 + Range.empty] do? It looks rather cryptic..
char[1+Range.empty] is a type. If
On Mon, Sep 6, 2010 at 18:47, Pelle wrote:
> On 09/04/2010 02:11 PM, Simen kjaeraas wrote:
>
>> Is there a way you could write an isStatic(expr) template? Using
>>>
>>
>> template isStatic( alias T ) {
>> enum isStatic = is( char[1+T] );
>> }
>>
>> unittest {
>> int n = 3;
>> assert( !isStatic!n
Apparently I can't post to D.learn from gmail without waiting for a review?
What the..?
Anyway, I've posted this:
On a related note, I always wanted to make a template to replace the
dreaded is(typeof('delegate literal'())); calls.
For example, instead of this:
enum bool isInputRange = is(type
Andrej Mitrovic wrote:
Apparently I can't post to D.learn from gmail without waiting for a review?
What the..?
Anyway, I've posted this:
On a related note, I always wanted to make a template to replace the
dreaded is(typeof('delegate literal'())); calls.
For example, instead of this:
enum bo
Am 06.09.2010 21:24, schrieb Andrej Mitrovic:
Apparently I can't post to D.learn from gmail without waiting for a review?
What the..?
Anyway, I've posted this:
On a related note, I always wanted to make a template to replace the
dreaded is(typeof('delegate literal'())); calls.
For example, in
Yeah, that could work:
template isInputRange(R)
{
enum bool isInputRange = __traits(compiles,
{
R r; // can define a range object
if (r.empty) {} // can test for empty
r.popFront; // can invoke next
auto h = r.front; // can get the front of t
I'd love to see this used more in Phobos. I don't know if there are any
drawbacks, but this looks and works nicely:
import std.stdio : writeln;
void main()
{
writeln(isInputRange!(N));
}
class N
{
N test;
bool empty()
{
return false;
}
@property
voi
On 09/06/2010 08:53 PM, Philippe Sigaud wrote:
On Mon, Sep 6, 2010 at 18:47, Pelle mailto:pelle.mans...@gmail.com>> wrote:
On 09/04/2010 02:11 PM, Simen kjaeraas wrote:
Is there a way you could write an isStatic(expr) template? Using
template isStatic( alias T ) {
Is this legal?:
enum a = "test";
a = "test2";
Because it seems to compile. But that shouldn't work afaik..?
I can't reassign other enum types:
enum b = 4;
b = 5; // error
which is expected.
Pelle Wrote:
> On 09/06/2010 08:53 PM, Philippe Sigaud wrote:
> > On Mon, Sep 6, 2010 at 18:47, Pelle
// ..snip
point3D p; // Da
p.x = 10;
p.y = 20;
p.z = 100;
point3D = = new point3D(10,20,30) // Njet
//etc
}
struct point {
int x;
int y;
}
struct point3D {
point p;
alias p this;
int z;
// NOPE :(
/*static point3D opcall(int _x, int _y, int
On 06/09/2010 22:36, BLS wrote:
point3D = = new point3D(10,20,30) // Njet
//etc
should be
point3D p3 = new point3D(10,20,30) // Njet
sorry
Andrej Mitrovic wrote:
I'd love to see this used more in Phobos. I don't know if there are any
drawbacks, but this looks and works nicely:
import std.stdio : writeln;
void main()
{
writeln(isInputRange!(N));
}
class N
{
N test;
bool empty()
{
return false;
}
BLS wrote:
On 06/09/2010 22:36, BLS wrote:
point3D = = new point3D(10,20,30) // Njet
//etc
should be
point3D p3 = new point3D(10,20,30) // Njet
sorry
Struct is value type, not reference type like class. You don't need
'new' to create it, just uncomment your constructor ('this') and r
Andrej Mitrovic wrote:
It does look nice. It would look even nicer if __traits gets renamed to meta.
By the way, there's no stopping writing
template isValidCode(alias code) { enum bool isValidCode =
__traits(compiles, code); }
:)
is(typeof( is used a lot in Phobos. There's some ~260 calls like that, a quick
search revealed. :p
Stanislav Blinov Wrote:
> If I remember correctly, it has been discussed not long ago that those
> is(typeof(...))s should really be __traits(compiles). Maybe it's just
> some code was written be
That still won't work. Observe:
import std.stdio : writeln;
void main()
{
writeln(isInputRange!(N));
}
class N
{
N test;
//~ bool empty() // oops, we"re not an input range anymore
//~ {
//~ return false;
//~ }
@property
void popFront()
{
}
@p
Andrej Mitrovic wrote:
is(typeof( is used a lot in Phobos. There's some ~260 calls like that, a quick
search revealed. :p
Hush! You're spoiling it! It's a part of intergalactic obfuscation plot ;p
Andrej Mitrovic wrote:
That still won't work. Observe:
Oops, sorry, I was too quick to conclude.
I have some D1 code that I'm transfering to D2, and it's using getchar. I think
I need to flush the buffer or something because the loop tends to skip:
import std.c.stdio;
import std.stdio;
void main()
{
char k;
for(int i = 0; i < 10; i++)
{
writef("Press key #%d:\t\n", i);
On Mon, Sep 6, 2010 at 23:31, Andrej Mitrovic wrote:
> That still won't work. Observe:
> template isInputRange(R)
> {
> enum bool isInputRange = isValidCode!(
> {
>R r;// can define a range object
>if (r.empty) {} // can test for empty
>r.popF
Andrej Mitrovic wrote:
Someone on the NGs started creating some user-friendly input functions,
something like getInput!char(variable), or similar. But I can't find the topic,
anyone know the link perhaps? It was fairly recent that someone posted it.
It was Jesse Phillips:
http://www.digita
Andrej Mitrovic:
> enum a = "test";
> a = "test2";
>
> Because it seems to compile. But that shouldn't work afaik..?
I have two open bug reports on this (and a third one was open by Don).
Bye,
bearophile
I'm sorry, but what does q{..} mean?
Philippe Sigaud Wrote:
> On Mon, Sep 6, 2010 at 23:31, Andrej Mitrovic
> wrote:
>
> > That still won't work. Observe:
>
>
>
> > template isInputRange(R)
> > {
> > enum bool isInputRange = isValidCode!(
> > {
> >R r;// can d
Thanks.
Stanislav Blinov Wrote:
> Andrej Mitrovic wrote:
>
> >
> > Someone on the NGs started creating some user-friendly input functions,
> > something like getInput!char(variable), or similar. But I can't find the
> > topic, anyone know the link perhaps? It was fairly recent that someone
>
Andrej Mitrovic:
> I'm sorry, but what does q{..} mean?
q{} is just a different syntax to write "" or ``
It's a controversial feature. q{} isn't recognized by editors as a string, so
they colour the syntax it contains normally as code, and not as a string. So
it's a bit useful if you want to g
Heh. I'd rather want text editors to use syntax highlighting on comments as
well, but use a different background color. Then I would know it's a comment
but it would also make any embedded code in the comment actually readable.
bearophile < bearophileh...@lycos.com> Wrote:
> Andrej Mitrovic:
>
I meant string literals. But comments as well.
Andrej Mitrovic Wrote:
> Heh. I'd rather want text editors to use syntax highlighting on comments as
> well, but use a different background color. Then I would know it's a comment
> but it would also make any embedded code in the comment actually r
On Fri, 20 Aug 2010 20:33:43 +, Iain Buclaw wrote:
> == Quote from Ersin Er (ersin...@gmail.com)'s article
>> Hi,
>> The following code compiles and outputs "1 = 1" as expected: 1 == 1 &&
>> writeln("1 = 1");
>> However, the following code fails to compile (although it should not):
>> 1 == 2 &
31 matches
Mail list logo