StackLanguge / stack-language

The official impilmentation of the Stack programming language created by BookOwl
4 stars 1 forks source link

File access #7

Closed BookOwl closed 8 years ago

BookOwl commented 8 years ago

We need to figure out what the interface for accessing files from Stack scripts should be.

towerofnix commented 8 years ago

fwrite, fappend, fread, freadlines, freadbytes?

BookOwl commented 8 years ago

We don't have a way to work with bytes with Stack. For opening files, how about 'file1.txt' fopen

towerofnix commented 8 years ago

'file1.txt' fopen fread?

BookOwl commented 8 years ago

Yes

towerofnix commented 8 years ago

What type of data is the result of 'file1.txt' fopen?

BookOwl commented 8 years ago

A file type that supports the file operations.

towerofnix commented 8 years ago

Okay :package:

BookOwl commented 8 years ago

I'll implement it.

towerofnix commented 8 years ago

kthx.

:P Though if you take a look at my stdlib branch you can see I've already got importing python modules working!

You should check it out.

BookOwl commented 8 years ago

Awesome!

towerofnix commented 8 years ago

https://github.com/StackLanguge/stack-language/commit/720c74b10a6cbdd709ba0c2aeea95fad2489b89c

jeandrek commented 8 years ago

Wow importing Python modules! Also can you do 1 fread to read from STDIN?

towerofnix commented 8 years ago

Why 1?

In theory you could do so, but you'd need to write a python script to get sys.stdin's path. :package:

Also like a lot of things here #23

BookOwl commented 8 years ago

Implemented by #23

jeandrek commented 8 years ago

Why 1?

Because 1 is the file descriptor for STDIN. (it may need casting or something though as it isn't a complete file object)

If not, you can still do '/dev/tty' fopen on UNIX-like systems. (but not windows)

towerofnix commented 8 years ago

Oh yes, that's true.

jeandrek commented 8 years ago

Oh yes, that's true.

oh wait you can already do that with '' input but you could use fwrite to write to stderr