daokoder / dao

Dao Programming Language
http://daoscript.org
Other
199 stars 19 forks source link

io.open() may create invalid stream #523

Open Night-walker opened 8 years ago

Night-walker commented 8 years ago
(dao) load stream
= none
(dao) f = io.open('.', 'r')
= FileStream[0x1210920]
kunal commented 6 years ago

Hello @daokoder,

I am getting started with this. Where should this be handled? As a part of "stream" module or a part of the platform?

dumblob commented 6 years ago

Hi @kunal, welcome to this project. I'm glad you're be willing to help us.

Could you please be more specific what you mean by "handled in the platform"? In kernel/daoPlatform.c there you can see Dao_OpenFile() calls directly fopen(). From what I found is it simply undefined if one tries to fopen a directory (see e.g. https://stackoverflow.com/a/18193383 ) and therefore we should check before trying to call fopen on a directory because I can't think of any use case for having a stream interface for a directory. Therefore @Night-walker calls it an invalid stream.

It's definitely to be corrected in modules/stream/dao_stream.c.

We're also trying hard to keep the Dao core as minimal as possible. If not absolutely necessary, we don't add such checks into the core, but rather to the user inputs (e.g. inputs from a programmer, which is the source code he's writing).

@daokoder your point of view?

kunal commented 6 years ago

Thanks, @dumblob for the response. Yes by the platform I meant core. Yes, I will work on fixing this in the stream module.

kunal commented 6 years ago

Any updates here? :)

dumblob commented 6 years ago

@kunal I think we shall maintain a separate git tree which will be used as "staging" (more or less according to this definition: https://lwn.net/Articles/324279/ ):

https://github.com/dumblob/dao

Could you just close your pull request to this repository and make the pull request to the staging repository?

@daokoder is being pretty busy during the last year or two and the project needs to get forward. @daokoder will of course stay as the main architect and maintainer of the project.

kunal commented 6 years ago

@dumblob Will do. Thank you.

dumblob commented 5 years ago

@kunal could you post your pull request to the repository https://github.com/dumblob/dao ? I would be happy to merge it.

kunal commented 5 years ago

@dumblob Yes I will. Have been busy with travels. Will try to do it asap.

kunal commented 5 years ago

@dumblob I have sent pull request. Can you also create a staging area for dao-modules? :) I am working on modules as well.

dumblob commented 5 years ago

Have been busy with travels. Will try to do it asap.

No need to hurry - I just wanted to make sure it's alright from your point of view.

I have sent pull request.

I'll review it in the next days :wink:.

Can you also create a staging area for dao-modules?

Done.