View mode: basic / threaded / horizontal-split · Log in · Help
January 30, 2008
forward references...again
Hi all,

I know this has been flagged as a bug before, but it doesn't seem to be getting fixed.
So I'm gonna see if i can fix it myself.

In its simplest form the following three files won't compile:

----
[ vec.d ]
module vec;
import mat;

struct Vec { 
 float x, y, z; 
 Mat mat() { Mat m; return m; }
}

[ mat.d ]
module mat;
import vec;

struct Mat { Vec cols[3]; }

[ main.d ]
import vec, matrix;

int main() { Vec v; Mat m; return 0; }
---- 

dmd -c matrix.d; will compile
dmd -c vec.d;  fails

However, its the parsing of matrix.d that fails when u try to compile vec.d.

Basically, on the first semantic pass of vec.d the module mat will get parsed causing
a semantic pass on struct Mat, which flags errors because it cannot determine the size of the struct.  Then it returns back down to the vec module and successfully determines the size of the Vec struct as 12, and returns back to the main driver
[d-lang.c:d_parse_file()] which exits because of the flagged errors.


Anyways, I'm looking for some feedback concerning how to fix this in an acceptable fashion.  From what I can see, this problem seems to have already made the code in many modules somewhat less than readable, to me at least.  So rather than placing another hack into the code my initial idea is to add an addition semantic pass prior to the first, to scan through each module, tail recursing through the imports only if they are needed to determine the size of aggregate types... or maybe this will just end up being a hack too and the first semantic pass should really be able to handle this... :D

Thoughts or feedback before I start on this, or reasons why I shouldnt waste my time ;)

kede
January 30, 2008
Re: forward references...again
"kede" <nobody@devnull.com> wrote in message 
news:fnont6$9om$1@digitalmars.com...

> Anyways, I'm looking for some feedback concerning how to fix this in an 
> acceptable fashion.

A way of fixing it in an _un_acceptable fashion would be to stick everything 
into one module.

> Thoughts or feedback before I start on this, or reasons why I shouldnt 
> waste my time ;)

Well, Walter doesn't feel that fixing this kind of bug is of the highest 
priority, despite its being the one that is run into the most often and 
which has no real workarounds.  But what can you do, the frontend's 
closed-source.

:(
January 30, 2008
Re: forward references...again
Jarrett Billingsley wrote:
> "kede" <nobody@devnull.com> wrote in message 
> news:fnont6$9om$1@digitalmars.com...
> 
>> Anyways, I'm looking for some feedback concerning how to fix this in an 
>> acceptable fashion.
> 
> A way of fixing it in an _un_acceptable fashion would be to stick everything 
> into one module.
> 
>> Thoughts or feedback before I start on this, or reasons why I shouldnt 
>> waste my time ;)
> 
> Well, Walter doesn't feel that fixing this kind of bug is of the highest 
> priority, despite its being the one that is run into the most often and 
> which has no real workarounds.  But what can you do, the frontend's 
> closed-source.

Backend, I think you meant to say.

--bb
January 30, 2008
Re: forward references...again
"Bill Baxter" <dnewsgroup@billbaxter.com> wrote in message 
news:fnoqnb$guj$1@digitalmars.com...
> Jarrett Billingsley wrote:
>> "kede" <nobody@devnull.com> wrote in message 
>> news:fnont6$9om$1@digitalmars.com...
>>
>>> Anyways, I'm looking for some feedback concerning how to fix this in an 
>>> acceptable fashion.
>>
>> A way of fixing it in an _un_acceptable fashion would be to stick 
>> everything into one module.
>>
>>> Thoughts or feedback before I start on this, or reasons why I shouldnt 
>>> waste my time ;)
>>
>> Well, Walter doesn't feel that fixing this kind of bug is of the highest 
>> priority, despite its being the one that is run into the most often and 
>> which has no real workarounds.  But what can you do, the frontend's 
>> closed-source.
>
> Backend, I think you meant to say.
>
> --bb

Well the frontend is open-source but it's not like anyone but Walter 
actually has the authority to change it.  You can submit patches but whether 
they make it in is entirely up to one guy.
January 30, 2008
Re: forward references...again
Jarrett Billingsley wrote:
> "Bill Baxter" <dnewsgroup@billbaxter.com> wrote in message 
> news:fnoqnb$guj$1@digitalmars.com...
>> Jarrett Billingsley wrote:
>>> "kede" <nobody@devnull.com> wrote in message 
>>> news:fnont6$9om$1@digitalmars.com...
>>>
>>>> Anyways, I'm looking for some feedback concerning how to fix this in an 
>>>> acceptable fashion.
>>> A way of fixing it in an _un_acceptable fashion would be to stick 
>>> everything into one module.
>>>
>>>> Thoughts or feedback before I start on this, or reasons why I shouldnt 
>>>> waste my time ;)
>>> Well, Walter doesn't feel that fixing this kind of bug is of the highest 
>>> priority, despite its being the one that is run into the most often and 
>>> which has no real workarounds.  But what can you do, the frontend's 
>>> closed-source.
>> Backend, I think you meant to say.
>>
>> --bb
> 
> Well the frontend is open-source but it's not like anyone but Walter 
> actually has the authority to change it.  You can submit patches but whether 
> they make it in is entirely up to one guy. 

I see what you mean.  Still, technically it does satisfy the definition 
of "open-source".  Practicality aside, anyone is free to start a new 
fork if they so choose, right?

--bb
January 30, 2008
Re: forward references...again
Jarrett Billingsley wrote:
> "Bill Baxter" <dnewsgroup@billbaxter.com> wrote in message 
> news:fnoqnb$guj$1@digitalmars.com...
>> Jarrett Billingsley wrote:
>>> "kede" <nobody@devnull.com> wrote in message 
>>> news:fnont6$9om$1@digitalmars.com...
>>>
>>>> Anyways, I'm looking for some feedback concerning how to fix this in an 
>>>> acceptable fashion.
>>> A way of fixing it in an _un_acceptable fashion would be to stick 
>>> everything into one module.
>>>
>>>> Thoughts or feedback before I start on this, or reasons why I shouldnt 
>>>> waste my time ;)
>>> Well, Walter doesn't feel that fixing this kind of bug is of the highest 
>>> priority, despite its being the one that is run into the most often and 
>>> which has no real workarounds.  But what can you do, the frontend's 
>>> closed-source.
>> Backend, I think you meant to say.
>>
>> --bb
> 
> Well the frontend is open-source but it's not like anyone but Walter 
> actually has the authority to change it.  You can submit patches but whether 
> they make it in is entirely up to one guy. 
> 
> 

If you submitted a patch that fixed the issues & had tests to prove it, 
I'm sure Walter wouldn't hesitate to integrate it. OTOH, given the way 
the frontend is architectured, those sorts of things would be a lot of work.
Top | Discussion index | About this forum | D home