Your examples make D look like a pretty unreadable language.
with(File("text.txt", "w")) write(["my" , "name" , "is" , "Jesse"].join(","), "!");
There's no clear indication that you're working on the text.txt inside the with, and write just magically changes target.
text.txt
with
write
Yeah, D programmers rearly utilize with even with limited scope it can hide the origin. The main thing here is to create a scope to automatically call close() like in Python.
close()
{ auto f = File("text.txt", "w"); f.write(["my" , "name" , "is" , "Jesse"].join(","), "!"); }
But D also provides an explicit cleanup since, not all cleanup is the same, and not everything is expected to clean up at scope exit
{ auto f = File("text.txt", "w"); scope(exit) f.close(); f.write(["my" , "name" , "is" , "Jesse"].join(","), "!"); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Your examples make D look like a pretty unreadable language.
There's no clear indication that you're working on the
text.txt
inside thewith
, andwrite
just magically changes target.Yeah, D programmers rearly utilize
with
even with limited scope it can hide the origin. The main thing here is to create a scope to automatically callclose()
like in Python.But D also provides an explicit cleanup since, not all cleanup is the same, and not everything is expected to clean up at scope exit