-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
News stdlib functions #305
base: master
Are you sure you want to change the base?
Conversation
@@ -176,6 +176,12 @@ pub fun create_dir(path: Text): Null { | |||
} | |||
} | |||
|
|||
pub fun delete_dir(path: Text): Null { | |||
if dir_exist(path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this if
is useless, rm -f
will ignore an error if it happened. it would be useful to check if its actually a file and not a directory or something, since rm -f
on a directory would fail
src/std/main.ab
Outdated
return unsafe $echo -n "{text}" | base64$ | ||
} | ||
|
||
pub fun decodeb64(encoded: Text): Text { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the point of naming it decodeb64
? does it stand for decode
b
ase 64
? in that case, its inconsistend naming with encode64
which i guess stands for encode
base 64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a human error. I'll put the b in base64 there. Do you think it would be okay? or give me another suggestion
} | ||
|
||
pub fun randint(min: Num, max: Num): Num { | ||
return unsafe $shuf -i "{min}-{max}" -n 1$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is quite controversial. is it widely present on most UNIX systems? does its behaviour change from platform to platform? how often is it maintained? does it generate secure random numbers? does it work with floats?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also this very obviously will break with negative numbers
create_dir("/tmp/amber-test") | ||
if dir_exist("/tmp/amber-test") { | ||
delete_dir("/tmp/amber-test") | ||
echo "deleted" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not check if the directory has actually been deleted
@@ -0,0 +1,4 @@ | |||
import * from "std" | |||
main { | |||
echo randint(1,1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not check if any weird range would output correct info, like if min would be greater than max
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made 1 random out of 1 because how to guess the result to pass the tests.
also, please include some description of the functions in the PR description |
I added easy functions but quite useful for what the language is based on