Re: Bug in Rdmd?

2016-06-13 Thread Jonathan Marler via Digitalmars-d-learn

On Tuesday, 14 June 2016 at 03:40:01 UTC, Adam D. Ruppe wrote:

On Tuesday, 14 June 2016 at 03:15:04 UTC, Jonathan Marler wrote:

It actually is a free function


no, it isn't, it is on File.

Your code doesn't compile on my dmd (and indeed it shouldn't on 
yours either unless you have a version mismatch. rdmd just 
calls dmd, it doesn't produce its own errors)


Shoot stupid mistake.  You were right Jeremy and Adam.  Thanks 
for replying and showing me my silly error.  I could have sworn 
byLine was a template and calling it with file was just 
UFCS...and I don't know how I was able to compile that with 
DMD...must have made a mistake somewhere.  Thanks again.


Re: Bug in Rdmd?

2016-06-13 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 14 June 2016 at 03:15:04 UTC, Jonathan Marler wrote:

It actually is a free function


no, it isn't, it is on File.

Your code doesn't compile on my dmd (and indeed it shouldn't on 
yours either unless you have a version mismatch. rdmd just calls 
dmd, it doesn't produce its own errors)


Re: Bug in Rdmd?

2016-06-13 Thread Jonathan Marler via Digitalmars-d-learn

On Tuesday, 14 June 2016 at 01:35:32 UTC, Jeremy DeHaan wrote:

On Tuesday, 14 June 2016 at 01:05:46 UTC, Jonathan Marler wrote:

This code doesn't seem to work with rdmd.  Is this a bug?

  import std.stdio : byLine;
  int main(string[] args)
  {
foreach(line; stdin.byLine) {
}
return 0;
  }

Compiler Output:
  Error: module std.stdio import 'byLine' not found


Try removing the 'byLine' from the import statement. The error 
message looks like it can't find the function 'byLine' in the 
std.stdio module. It isn't a free function, but one of File's 
methods.


It actually is a free function (not a method on the File object). 
 This works if you compile it with dmd, just not with rdmd.




Bug in Rdmd?

2016-06-13 Thread Jonathan Marler via Digitalmars-d-learn

This code doesn't seem to work with rdmd.  Is this a bug?

  import std.stdio : byLine;
  int main(string[] args)
  {
foreach(line; stdin.byLine) {
}
return 0;
  }

Compiler Output:
  Error: module std.stdio import 'byLine' not found


nested inout return type

2016-06-13 Thread Simon Bürger via Digitalmars-d-learn
I'm writing a custom (originally multi-dimensional) Slice-type, 
analogous to the builtin T[], and stumbled upon the problem that 
the following code won't compile. The workaround is simple: just 
write the function three times for mutable/const/immutable. But 
as "inout" was invented to make that unneccessary I was wondering 
if there is a clever way to make this work.



struct Slice(T)
{
T* ptr;
size_t length;

Slice!(inout(T)) opSlice(size_t a, size_t b) inout
{
return Slice!(inout(T))(ptr+a, b-a);
}
}


how to get rid of "cannot deduce function from argument types" elegantly

2016-06-13 Thread Christian Köstlin via Digitalmars-d-learn
I made a small (could be reduced further) example that creates and walks
a templated binary tree. The tree also gets a factory function to use
type deduction to conveniently construct a tree. Unfortunately this does
not compile, if I remove the three ugly methods between /* these should
go */ comments.

```
fibertest.d(49): Error: template fibertest.tree cannot deduce function
from argument types !()(int, typeof(null), typeof(null)), candidates are:
fibertest.d(41):fibertest.tree(T)(T node, Tree!T left, Tree!T right)
```

Is there a more elegant way to fix this?

Another fix would be to provide 4 factory functions like this (still not
really nice):
```
tree(Tree!T left, T node, Tree!T right) {...}
tree(T node, Tree!T right) {...}
tree(Tree!T left, T node) {...}
tree(T node) {...}
```

```d
import std.concurrency, std.stdio, std.range;

class Tree(T) {
  Tree!T left;
  T node;
  Tree!T right;

  this(Tree!T left, T node, Tree!T right) {
this.left = left;
this.node = node;
this.right = right;
  }

  auto inorder() {
return new Generator!T(() => yieldAll(this));
  }

  private void yieldAll(Tree!T t) {
if (t is null) return;

yieldAll(t.left);
yield(t.node);
yieldAll(t.right);
  }
}

/* these should go */

Tree!T tree(T)(typeof(null) left, T node, typeof(null) right) {
  return new Tree!T(null, node, null);
}
Tree!T tree(T)(Tree!T left, T node, typeof(null) right) {
  return new Tree!T(left, node, null);
}
Tree!T tree(T)(typeof(null) left, T node, Tree!T right) {
  return new Tree!T(null, node, right);
}

/* these should go */

Tree!T tree(T)(Tree!T left, T node, Tree!T right) {
  return new Tree!T(left, node, right);
}

void main(string[] args) {
  // /3
  //   /2
  //  1
  auto t1 = tree(tree(tree(null, 1, null), 2, null), 3, null);
  // 1
  //  \2
  //\3
  auto t2 = tree(null, 1, tree(null, 2, tree(null, 3, null)));
  writeln(t1.inorder());
  writeln(t2.inorder());
  writeln(t1.inorder().array == t2.inorder().array);
}
```


Re: Gotchas for returning values from blocks

2016-06-13 Thread Era Scarecrow via Digitalmars-d-learn

On Monday, 13 June 2016 at 14:16:58 UTC, jmh530 wrote:
So returning a reference to something on the stack is a bad 
idea, but copying the value would be fine.


 This is easy enough to get wrong elsewhere too. I recall having 
an issue with a foreach, until I added a 'ref' to it. Looking at 
the addresses all pointing to the same spot (the temporary) which 
can add curiously subtle bugs, or blatantly obvious ones.


Re: Parse File at compile time, but not embedded

2016-06-13 Thread ketmar via Digitalmars-d-learn

On Sunday, 12 June 2016 at 01:39:11 UTC, Joerg Joergonson wrote:
This doesn't seem to be the case though in more complex 
examples ;/


it is.


My code is almost identical do what you have written


your code is *completely* different. that's why there are no 
traces of CTFE values in my sample. it's not that hard to find 
out that my code has no functions at all, so no code for 'em can 
be generated.


Re: What's up with GDC?

2016-06-13 Thread Joerg Joergonson via Digitalmars-d-learn

On Monday, 13 June 2016 at 16:46:38 UTC, Adam D. Ruppe wrote:

On Sunday, 12 June 2016 at 14:22:54 UTC, Joerg Joergonson wrote:
Error: undefined identifier 'Sleep' in module 'core.thread', 
did you mean function 'Sleep'?


It is supposed to be `Thread.sleep(1.seconds);`

I'm pretty sure the capital Sleep() is supposed to be private 
(that is the OS-specific Windows api call).




Ok, I tried both and Sleep was the one that worked for some odd 
ball reason.  Then it seemed to stop working I think(I tried it 
in a different spot)... maybe user error.


Basically keeping the event loop uses around 12% cpu and 12MB 
of memory.


That's weird, it just sleeps until a message comes in from the 
OS. On my computer, programs sit at 0% like you'd expect, and 
my guitest program (which has text areas, buttons, menu, etc) 
eats ~1.7 MB, both 32 and 64 bit versions.


Are you running some other program that might be sending a lot 
of broadcast messages?




Not that I know of. I haven't tried running it outside VS though 
so it might be doing something weird. I'll investigate further 
when I get a chance and get further down the road.


About the WM size thing, I haven't had a problem with it except 
for the weird vertical shifting. It doesn't use any more cpu when 
constantly resizing.




Re: Access private member

2016-06-13 Thread Jacob Carlborg via Digitalmars-d-learn

On 2016-06-13 17:00, Basile B. wrote:


Unless It's you Jacob who have proposed Orange to phobos in 2012. And
then since refused it's not developed at all. IIRC it's even not
possible to compile it with DUB.


Yes, I've written Orange and proposed it to Phobos. Not sure what you 
mean with "refused" and "not developed".


Orange is a part of Mambo [1] which is avilable using Dub [2].

[1] https://github.com/jacob-carlborg/mambo/tree/master/mambo/serialization

[2] http://code.dlang.org/packages/mambo

--
/Jacob Carlborg


Re: Accessing COM Objects

2016-06-13 Thread Incognito via Digitalmars-d-learn

On Monday, 13 June 2016 at 19:11:59 UTC, John wrote:

On Monday, 13 June 2016 at 17:38:41 UTC, Incognito wrote:
Cool. Oleview gives me the idl files. How to convert the idl 
files to d or possibly c?


Would I just use them in place of IUnknown once I have the 
interface?


In OleView you can save the IDL file, then run another tool, 
midl.exe, on the IDL file. That will generate the C headers. 
But you'd then have to translate that to D by hand.


I have written a tool that takes a COM type library and 
automatically converts it to a D source file. I could finish it 
off over the next few days and put the source on GitHub if 
you're interested.


That would be great! With it I might be able to put a nice 
wrapper around Photoshop for use with D. Others mind find it 
useful too as other programs still use COM.







Re: Accessing COM Objects

2016-06-13 Thread John via Digitalmars-d-learn

On Monday, 13 June 2016 at 17:38:41 UTC, Incognito wrote:
Cool. Oleview gives me the idl files. How to convert the idl 
files to d or possibly c?


Would I just use them in place of IUnknown once I have the 
interface?


In OleView you can save the IDL file, then run another tool, 
midl.exe, on the IDL file. That will generate the C headers. But 
you'd then have to translate that to D by hand.


I have written a tool that takes a COM type library and 
automatically converts it to a D source file. I could finish it 
off over the next few days and put the source on GitHub if you're 
interested.


Re: What's up with GDC?

2016-06-13 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 11 June 2016 at 04:20:38 UTC, Joerg Joergonson wrote:

BTW I make your code a bit better with resizing

case WM_SIZING:
goto size_changed;
break;


I left that out intentionally because it lagged on my computer... 
so I wanted it to stay blank.


Maybe it can be made more efficient though.


Re: Accessing COM Objects

2016-06-13 Thread Incognito via Digitalmars-d-learn

On Monday, 13 June 2016 at 07:40:09 UTC, John wrote:

On Monday, 13 June 2016 at 01:22:33 UTC, Incognito wrote:
I've been reading over D's com and can't find anything useful. 
It seems there are different ways:


http://www.lunesu.com/uploads/ModernCOMProgramminginD.pdf

which is of no help and requires an idl file, which I don't 
have.


Then theres this

http://wiki.dlang.org/COM_Programming

which is also of no help:

import std.stdio;

import std.stdio, core.sys.windows.com, 
core.sys.windows.windows, std.exception, std.meta, std.traits;
import std.utf, core.stdc.stdlib, core.sys.windows.objidl, 
core.sys.windows.ole2;

pragma(lib, "ole32.lib");


GUID Guid(string str)()
{
static assert(str.length==36, "Guid string must be 36 
chars long");
enum GUIDstring = "GUID(0x" ~ str[0..8] ~ ", 0x" ~ 
str[9..13] ~ ", 0x" ~ str[14..18] ~
", [0x" ~ str[19..21] ~ ", 0x" ~ str[21..23] ~ ", 0x" 
~ str[24..26] ~ ", 0x" ~ str[26..28]
~ ", 0x" ~ str[28..30] ~ ", 0x" ~ str[30..32] ~ ", 0x" 
~ str[32..34] ~ ", 0x" ~ str[34..36] ~ "])";

return mixin(GUIDstring);
}

int main(string[] argv)
{

	// Adobe Photoshop App 9.0 CLSID 
{c09f153e-dff7-4eff-a570-af82c1a5a2a8}
	// Adobe Photoshop App 9.1 CLSID 
{6DECC242-87EF-11cf-86B4-44455354}


	auto CLSID_DOMDocument60 = 
Guid!("6DECC242-87EF-11cf-86B4-44455354");

auto iid = IID_IUnknown;

void* pUnk;
	auto hr = CoCreateInstance(_DOMDocument60, null, 
CLSCTX_ALL, , );

if (FAILED(hr))
throw new Exception("Error!");

writeln("Hello D-World!");
return 0;
}

Maybe my CLSID's are wrong. Got them from the registry. The 
exception triggers each time. Even if it worked, I wouldn't 
know how to use it.


I can do this stuff in C# by simply dragging and dropping a 
dll into the references and it works fine but is a bit slow. I 
was hoping I could speed things up using D but it seems like 
COM isn't really supported, despite what several references 
say.


COM is supported in D. The difference is that C# hides all the 
plumbing behind nice classes.


You're going to need Photoshop's COM interface to do anything 
with it. If you don't have a C header that you can translate 
into D, you could use a tool included in the Windows SDK called 
OleView. It will peek inside COM  libraries and give you the 
interface definitions.


As to why CoCreateInstance isn't working, make sure you're 
calling CoInitialize or CoInitializeEx beforehand. If it's 
still failing, use std.windows.syserror.sysErrorString(hr) to 
see if it gives you a reason. Otherwise, CLSCTX_ALL might be 
the culprit - try using CLSCTX_SERVER instead.



Cool. Oleview gives me the idl files. How to convert the idl 
files to d or possibly c?


Would I just use them in place of IUnknown once I have the 
interface?




Re: Access private member

2016-06-13 Thread Basile B. via Digitalmars-d-learn

On Monday, 13 June 2016 at 15:00:06 UTC, Basile B. wrote:

On Monday, 13 June 2016 at 14:30:13 UTC, Basile B. wrote:

On Monday, 13 June 2016 at 11:27:31 UTC, Jacob Carlborg wrote:

On 2016-06-13 09:54, Pierre wrote:

Thank you i will try it.


You don't need to involve the constructor. You can use 
.tupleof, as I mentioned [1] [2].


[1] http://forum.dlang.org/post/njlohq$1n99$1...@digitalmars.com
[2] http://forum.dlang.org/post/njlop0$1ngk$1...@digitalmars.com


I understand that web devels needs to dump 47 bytes and send 
them at 8759 miles in 200 ms, but this serialization scheme is 
not good for object streaming, e.g store a full GUI in a 
resource file. Nobody will ever use flatbuffer or message pack 
to store a GUI...lol.


oops I think I've replied to another thread on another board :/

Unless It's you Jacob who have proposed Orange to phobos in 
2012. And then since refused it's not developed at all. IIRC 
it's even not possible to compile it with DUB.


https://www.youtube.com/watch?v=YJO4-aa6PCI=PLuhnsen8iS5ltHofd21TWBx-bqmR9V8RU=14=False

now you know the origin of the hat ;)


Re: What's up with GDC?

2016-06-13 Thread Adam D. Ruppe via Digitalmars-d-learn

On Sunday, 12 June 2016 at 14:22:54 UTC, Joerg Joergonson wrote:
Error: undefined identifier 'Sleep' in module 'core.thread', 
did you mean function 'Sleep'?


It is supposed to be `Thread.sleep(1.seconds);`

I'm pretty sure the capital Sleep() is supposed to be private 
(that is the OS-specific Windows api call).



Basically keeping the event loop uses around 12% cpu and 12MB 
of memory.


That's weird, it just sleeps until a message comes in from the 
OS. On my computer, programs sit at 0% like you'd expect, and my 
guitest program (which has text areas, buttons, menu, etc) eats 
~1.7 MB, both 32 and 64 bit versions.


Are you running some other program that might be sending a lot of 
broadcast messages?


Do you know if there is a way to get the largest used memory 
chunks and what is using them? That might tell the story!


idk


Re: Access private member

2016-06-13 Thread Basile B. via Digitalmars-d-learn

On Monday, 13 June 2016 at 14:30:13 UTC, Basile B. wrote:

On Monday, 13 June 2016 at 11:27:31 UTC, Jacob Carlborg wrote:

On 2016-06-13 09:54, Pierre wrote:

Thank you i will try it.


You don't need to involve the constructor. You can use 
.tupleof, as I mentioned [1] [2].


[1] http://forum.dlang.org/post/njlohq$1n99$1...@digitalmars.com
[2] http://forum.dlang.org/post/njlop0$1ngk$1...@digitalmars.com


I understand that web devels needs to dump 47 bytes and send 
them at 8759 miles in 200 ms, but this serialization scheme is 
not good for object streaming, e.g store a full GUI in a 
resource file. Nobody will ever use flatbuffer or message pack 
to store a GUI...lol.


oops I think I've replied to another thread on another board :/

Unless It's you Jacob who have proposed Orange to phobos in 2012. 
And then since refused it's not developed at all. IIRC it's even 
not possible to compile it with DUB.


Re: Access private member

2016-06-13 Thread Basile B. via Digitalmars-d-learn

On Monday, 13 June 2016 at 11:27:31 UTC, Jacob Carlborg wrote:

On 2016-06-13 09:54, Pierre wrote:

Thank you i will try it.


You don't need to involve the constructor. You can use 
.tupleof, as I mentioned [1] [2].


[1] http://forum.dlang.org/post/njlohq$1n99$1...@digitalmars.com
[2] http://forum.dlang.org/post/njlop0$1ngk$1...@digitalmars.com


I understand that web devels needs to dump 47 bytes and send them 
at 8759 miles in 200 ms, but this serialization scheme is not 
good for object streaming, e.g store a full GUI in a resource 
file. Nobody will ever use flatbuffer or message pack to store a 
GUI...lol.


Re: Gotchas for returning values from blocks

2016-06-13 Thread jmh530 via Digitalmars-d-learn

On Monday, 13 June 2016 at 01:41:07 UTC, Mike Parker wrote:


Everything works fine in your example because 'new' always 
allocates on the heap. Anything allocated on the stack is not 
guaranteed to be valid after the scope exits:


struct Foo
{
int baz;
~this() { baz = 1; }
}

void main()
{
import std.stdio : writeln;

Foo* foo;
{
Foo bar = Foo(10);
foo = 
}
//bar is now out of scope
assert(foo.baz == 10);
}

Struct constructors are always run when exiting a scope. More 
importantly, the pointer to bar is only valid until the stack 
address where it lives is overwritten by another stack 
allocation. In this example, there's no chance for that to 
happen before I access it, but it could happen at any time.


So returning a reference to something on the stack is a bad idea, 
but copying the value would be fine.


Re: Access private member

2016-06-13 Thread Jacob Carlborg via Digitalmars-d-learn

On 2016-06-13 09:54, Pierre wrote:

Thank you i will try it.


You don't need to involve the constructor. You can use .tupleof, as I 
mentioned [1] [2].


[1] http://forum.dlang.org/post/njlohq$1n99$1...@digitalmars.com
[2] http://forum.dlang.org/post/njlop0$1ngk$1...@digitalmars.com

--
/Jacob Carlborg


Re: Access private member

2016-06-13 Thread Basile B. via Digitalmars-d-learn

On Monday, 13 June 2016 at 07:53:08 UTC, Jacob Carlborg wrote:

On 2016-06-13 09:49, Jacob Carlborg wrote:


For fields, used .tupleof, for other symbols, use a pointer.


Here's an example [1] of accessing a field using the name of 
the field as a string. It will bypass private.


That module [1] contains some generic functionality for working 
with fields which you would need for serialization. Or you can 
use the whole serialization library directly [2] ;)


[1] 
https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L123


[2] https://github.com/jacob-carlborg/orange


There's also the IZ serializer. It's based on accessors (called 
property descriptor) to read and write private or protected 
fields. Actually it's never a good idea to directly access them. 
Usually they're not hidden for anything (e.g the count of items 
in a list, the setter update the list...)


pd: 
https://github.com/BBasile/iz/blob/master/import/iz/properties.d
ser: 
https://github.com/BBasile/iz/blob/master/import/iz/serializer.d


Re: Access private member

2016-06-13 Thread Jacob Carlborg via Digitalmars-d-learn

On 2016-06-13 09:49, Jacob Carlborg wrote:


For fields, used .tupleof, for other symbols, use a pointer.


Here's an example [1] of accessing a field using the name of the field 
as a string. It will bypass private.


That module [1] contains some generic functionality for working with 
fields which you would need for serialization. Or you can use the whole 
serialization library directly [2] ;)


[1] 
https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L123


[2] https://github.com/jacob-carlborg/orange

--
/Jacob Carlborg


Re: Access private member

2016-06-13 Thread Pierre via Digitalmars-d-learn

Thank you i will try it.



Re: Access private member

2016-06-13 Thread Jacob Carlborg via Digitalmars-d-learn

On 2016-06-13 09:43, Pierre wrote:

Hi,
I would like to know how can i access private member of class from
outside ?
I think about serialization for instance, serializer must have access to
protected attributes. How this is done ?
Thank you.


For fields, used .tupleof, for other symbols, use a pointer.

--
/Jacob Carlborg


Re: Access private member

2016-06-13 Thread Basile B. via Digitalmars-d-learn

On Monday, 13 June 2016 at 07:43:09 UTC, Pierre wrote:

Hi,
I would like to know how can i access private member of class 
from outside ?
I think about serialization for instance, serializer must have 
access to protected attributes. How this is done ?

Thank you.


You can perform the introspection in the class itself, e .g in 
the __ctor.





Access private member

2016-06-13 Thread Pierre via Digitalmars-d-learn

Hi,
I would like to know how can i access private member of class 
from outside ?
I think about serialization for instance, serializer must have 
access to protected attributes. How this is done ?

Thank you.


Re: Accessing COM Objects

2016-06-13 Thread John via Digitalmars-d-learn

On Monday, 13 June 2016 at 01:22:33 UTC, Incognito wrote:
I've been reading over D's com and can't find anything useful. 
It seems there are different ways:


http://www.lunesu.com/uploads/ModernCOMProgramminginD.pdf

which is of no help and requires an idl file, which I don't 
have.


Then theres this

http://wiki.dlang.org/COM_Programming

which is also of no help:

import std.stdio;

import std.stdio, core.sys.windows.com, 
core.sys.windows.windows, std.exception, std.meta, std.traits;
import std.utf, core.stdc.stdlib, core.sys.windows.objidl, 
core.sys.windows.ole2;

pragma(lib, "ole32.lib");


GUID Guid(string str)()
{
static assert(str.length==36, "Guid string must be 36 chars 
long");
enum GUIDstring = "GUID(0x" ~ str[0..8] ~ ", 0x" ~ 
str[9..13] ~ ", 0x" ~ str[14..18] ~
", [0x" ~ str[19..21] ~ ", 0x" ~ str[21..23] ~ ", 0x" ~ 
str[24..26] ~ ", 0x" ~ str[26..28]
~ ", 0x" ~ str[28..30] ~ ", 0x" ~ str[30..32] ~ ", 0x" 
~ str[32..34] ~ ", 0x" ~ str[34..36] ~ "])";

return mixin(GUIDstring);
}

int main(string[] argv)
{

	// Adobe Photoshop App 9.0 CLSID 
{c09f153e-dff7-4eff-a570-af82c1a5a2a8}
	// Adobe Photoshop App 9.1 CLSID 
{6DECC242-87EF-11cf-86B4-44455354}


	auto CLSID_DOMDocument60 = 
Guid!("6DECC242-87EF-11cf-86B4-44455354");

auto iid = IID_IUnknown;

void* pUnk;
	auto hr = CoCreateInstance(_DOMDocument60, null, 
CLSCTX_ALL, , );

if (FAILED(hr))
throw new Exception("Error!");

writeln("Hello D-World!");
return 0;
}

Maybe my CLSID's are wrong. Got them from the registry. The 
exception triggers each time. Even if it worked, I wouldn't 
know how to use it.


I can do this stuff in C# by simply dragging and dropping a dll 
into the references and it works fine but is a bit slow. I was 
hoping I could speed things up using D but it seems like COM 
isn't really supported, despite what several references say.


COM is supported in D. The difference is that C# hides all the 
plumbing behind nice classes.


You're going to need Photoshop's COM interface to do anything 
with it. If you don't have a C header that you can translate into 
D, you could use a tool included in the Windows SDK called 
OleView. It will peek inside COM  libraries and give you the 
interface definitions.


As to why CoCreateInstance isn't working, make sure you're 
calling CoInitialize or CoInitializeEx beforehand. If it's still 
failing, use std.windows.syserror.sysErrorString(hr) to see if it 
gives you a reason. Otherwise, CLSCTX_ALL might be the culprit - 
try using CLSCTX_SERVER instead.


Re: Fibers, what for?

2016-06-13 Thread chmike via Digitalmars-d-learn

On Monday, 13 June 2016 at 00:57:11 UTC, Alex Parrill wrote:
This is misleading. Any sort of cooperative system needs 
synchronization when two or more tasks try to access the same 
data, whether those "tasks" are OS threads, fibers, different 
machines on a network, etc.


That is true. Sorry. What I meant is that with fibers the yield 
is performed in well defined locations it could be in blocking 
calls like read() or write() or when yield is called.
For this reason it is simpler to synchronize access to shared 
ressources with fibers than with threads. It's thus POSSIBLE to 
write code that doesn't need synchronization even when shared 
ressources are used.


Note also that the synchronization mechanism can be much simpler 
and efficient than the one needed with threads.


With threads you MUST allways synchronize access to shared 
ressources and protect critical sections of your code, or use 
specially crafted none blocking data structures using atomic 
operations.