Lartu / ldpl

COBOL-like programming language that compiles to C++. With serious dinosaurs with neckties and briefcases 🦕💼
https://www.ldpl-lang.org/
Apache License 2.0
158 stars 24 forks source link

List files in directory #118

Closed Lartu closed 5 years ago

Lartu commented 5 years ago

While we provide ways to read from and write to files in directories, we don't provide any ways to LIST the contents of a directory. We need that in LDPL.

I'd recommend some syntax like LIST CONTENTS OF DIRECTORY <string-expression> IN <string-list>

It should be portable, though, and that's where the problem lies. Any thoughts? Should we go ahead and just execute ls -l under linux and dir in windows and parse accordingly or any of you has got any better ideas? :thinking:

arielf212 commented 5 years ago

I don't think this should have special syntax, especially since we already have a way to do this easily, as you have already mentioned.

dgarroDC commented 5 years ago

I would be nice to haven a cross platform way of doing it.

Lartu commented 5 years ago

I don't think this should have special syntax, especially since we already have a way to do this easily, as you have already mentioned.

What way? :thinking: In fact I realized we were lacking this because I needed a way to load all files in a directory and I noticed I had no way of knowing what files were there.

Lartu commented 5 years ago

Added in 4582c77a76ca5700cb7dfb8f1f21c3cf35d37e57. The syntax is the one suggested above. On my way to document it.

Lartu commented 5 years ago

Documented here.

arielf212 commented 5 years ago

it took me some time, but I managed to do it. here is my implementation of getting files inside directories using just ldpl, which you can take a look at if you want. it is cross-platform too.

Lartu commented 5 years ago

Woah, this is wonderful! I added the statement to keep the language simple to use, but what you've done is incredible!! Kudos to you!

Lartu commented 5 years ago

You know, @fireasembler, one of the things I like the most about developing LDPL (with you all) is when people like you or @dvkt or @carbontwelve come and show me things at the moment I didn't think were possible with LDPL. Not only it is a great satisfaction to see what the language is capable of, but it makes me very happy to be surrounded with such capable people (and, on top of that, interested in the language). So, doble kudos and thanks to you all!

That said, I was thinking that using what you've written you could write a library to check the current operating system. That'd be really useful!

(Also, I'm using your CSVLibrary for a univeristy project I'm working on, so thanks for that!)

arielf212 commented 5 years ago

@Latru It's just that I think that adding too many statements to the language will make it too complex for it's own needs. Maybe adding a macro system to allow for user defined statements will be better?

Lartu commented 5 years ago

While that is true, I do love when languages are a big toolbox that have things already cooked and done for you. When I want to read a CSV I don't want to program myself a CSV library, I want to read said CSV and get stuff done. PHP is great in this, Python too. I would like that kind of "I can use this language to do this and this easily" in LDPL. Despite its limitations.

arielf212 commented 5 years ago

Then maybe introducing a standard library would be a better choice.

I am just worried that adding too many things as keywords (or in our case, key sentences) will make the language too hard to read and use. It's already really hard to find the thing I need in the documentation.

Lartu commented 5 years ago

Hmmm... well in that case we may need not only a standard library, but also a better documentantion. I agree with you, a lib may be in order.