h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
311 stars 23 forks source link

Line information? #67

Closed ghost closed 3 years ago

ghost commented 3 years ago

I want to gather line inf in min files. And i found a method to do that thing: (("" (int) expect)('line dget))try via using dict:error which returned from try func. But this is a hacky method and if i define it in a module and evaluate(eval) it, then i see 1 as file number and <eval> as file name when get it with 'filename symbol. Same thing is for <parse> as file name.

Is there a really line method? or just i cannot find it in Min Lang?

< "But your lang is so good! You must improve that or somebody else." >

I added some utilities in my repo if you want to look it.

h3rald commented 3 years ago

Hey!

What a... creative method to get line information! 😜

You are right, that would be a good addition to the language, and easy to add too!

As a matter of fact I added it already today in the next branch... it's a new symbol called line-info that returns a dictionary containing:

...of the currently-interpreted symbol (which is the line-info symbol itself!) -- that gives you a very accurate position within the file. That's the same information I use to construct the stack trace in errors... and saved along with every symbol instance by the min parser.

I'll release it along with v0.28.0, probably this weekend.

EDIT Nice min utilities you created in your repo! Glad you are spending some time learning and using min! If you have any suggestion on how to improve things, just post it here as an issue: at worst I won't implement it, but if I like it and I find the time I will!

ghost commented 3 years ago

Sure 😄 ! Thank you.

h3rald commented 3 years ago

Implemented & released 😊