Anyprint: use any language's print statements in Python
github.com
github.com
https://sites.google.com/site/arclanguagewiki/more/list-of-l...
Works with both Scheme and Common Lisp, two most popular Lisps out there. Nobody uses it because paredit/parinfer is just too convenient, but the option is there.
pr<TAB> ---> print('%cursor%', %cursor%) echo "hello world"
echo("hello world")
and as a bonus, also the following: "hello world".echo> print("OK")
> print "OK"
> ("OK %d"):format(1)
I've seen some funky (ab)use of these, people using literal strings and tables and functions named class and similar to do:
> class "Something" {
> -- ...
> }
Hell, it even allows you to do this:
> somefunc "1string" "2string" "3string" > somefunc {} {} {}
You try to figure out how to do something, you see 3 different solutions and you ask yourself, what's the difference? What's more correct? Will I need one over the other? Are they compatible? Is one way better supported than the other?
The amount of time I've spent looking up differences between two APIs or two paradigms in Typescript is seriously ridiculous. And it feels really bad to not recognize something you've done before because it's written differently.
Common culprits: require() and imports, the countless ways of creating classes, the crazy amount of different ways to implement similar or identical workflows in webpack and pretty much the entire JS ecosystem in general.
Ironically, this is touted as a strength of Powershell. Speaking of which, this code supports none of Powershell's Write-Host variants.
I've always wondered this: would it be that bad, if you could easily guarantee that all those formats really are equivalent? (maybe by being able to check a unique identifier of the function to which the expression is going to be compiled).
In the case of this library, the semantics are simple and clear: I have a string object, and I want its contents to be poured on a predefined output device; maybe converting on-the-fly some escape characters in the string to the values of some parameters.
Provided that you don't deviate from this specified meaning, is it that bad that the language accepts any common syntax?
I understand the "being harder to recognize what it is doing", but I think that might be somewhat alleviated by the feature I said above of unambiguously resolving to a single entity in the programming language.
Maybe I'm just bad programmer, but I whole heartedly embrace languages that let me express myself in a way I want to. Big part of my day is dealing/writing/converting stuff to Python and part of me wishes there wasn't "the Zen way" to do things, but instead I could express myself, but this kind a goes beyond Python in a sense that it doesn't have the syntax I would like to use.
I'm by no means saying that JavaScript is any better. So far my personal favorite language has been Ruby (and not the Rails way), for some reasons it feel like with Ruby I can just tell the code what to do instead of having to explicitly command it to do what I want step by step.
I recently read the statement that "If you can solve parsing Perl, you solve the Halting Problem "(http://www.perlmonks.org/?node_id=663393). This is not a joke, it's serious.
Python and Go keep their promise to stay simple. However I believe, metaclasses, asynchronous programming and constructs like "yield from" and the whole itertools library could be better engineered. And lastly with new approved PEPs like concerning string interpolation etc., I believe Python is making compromises in its core ideology. In contrast, in go if you want to allocate something you just use make(), if you want your code to run concurrently you just use "go", if you want to send messages between threads, you just use channels. The complexity is well hidden in the language itself.
What I don't like in Java for example is that, as a general purpose language, in each version new features are added. And these new features add complexity, and complexity leads to mistakes.
Perl I understand, it was designed as the first postmodern programming language. Javascript was written in a very short time and intended to be a browser scripting language. But Typescript?, with Typescript there is no excuse. I guess, this is Microsoft's policy: Worse is better, make everyone (or at least revenue sources) happy. You want feature x, they add it, you want lambdas, they add it etc.
Maybe I'm a bit tired of hassling through chaos, but I want my codebase to be structured. If I don't like an API, I take my time and write a simpler abstraction. One programming advice stuck in my mind from the Art of Linux Programming: you should focus on data structures (a.k.a structuring).
I think this advice is true for all aspects of life. You need to set aside a place for your things, if you want to live/work in a tidy environment. You need to plan your day, if you don't want to fall apart. You need folders to organize your e-mail/documents. You need to structure your programs in meaningful abstractions into seperate modules/subroutines.
It's ES5, ES6 etc that is adding to it.
Okay I have to admit I love this one.
Also found in D.
And, frustratingly, did not get past the C++ committee.
writeln(mul(add(x, 5), 30))
vs.
x.add(5).mul(30).writeln()
print 'hello'
f = open(file, 'w')
print>>f, 'world'
It just feels more "powerful" than Py3k's print(somestring, file=someopenfile)But less obvious and readable, which is anti pythonic. If you want "power" over readability, there is ruby/perl.
Print chevron is super awful, it's unreadable, hard to remember and difficult to search for.
The print function was a welcome improvement: it's not a statement (so can be used in a lambda, no need to fall back to sys.stdout.write), it doesn't use weird-ass syntax to redirect or suppress the final newline and it's more extensible (e.g. "end" or "flush" kwargs would have been… challenging to add to the keyword version)
fprint = lambda string: print(string, file=somefile)
and use fprint all over the placethat little chevron trick is bad imo
open my $file, '>', 'hello';
print{$file} "Hello";Er… what?
Python doesn't have braces, it has plenty of parenthesis. In fact, Python 3 added more since it upgraded several keywords to functions (not just print but also exec, and some forms of re-raising)
That this is so little known is why we have a complicated future.exec_, which is entirely needless! (https://stackoverflow.com/a/26098101/1763356)
That's not really true, although the syntactic compatibility does make for conveniently trivial cross-compatible code, Python 3 did not "remove the old, braceless version" it converted exec from a keyword (which could accept a single tuple parameter) to a builtin function (which takes up to 3 parameters). Which had the side-effect of requiring parenthesis.
Incidentally, the print-tuple-trick is cute, I hadn't considered it.
(format t "hello ~a!" name)
for completeness... (prn "hello world")
I was actually just looking into adding a hook for an automatic AST transformer so I could possibly call into Hylang. (format t "~{~a~^, ~}" list) (format t "~{~<~%~1,40:;~A~> ~}"
'("these" "words" "will" "be" "wrapped" "to" "40" "characters"))
and the other `format` insanity in: http://cybertiggyr.com/fmt/fmt.pdf printf("printf %d\n", 10);
fmt.Println("hello")
cout << "Hello, C++!" << endl;
Print["Hello from Mathematica!"]
console.log("yes");
System.out.printf("java stuff\n");
Ada.Text_IO.Put_Line("Ada is cool")
Really funny, including the testimonials:> Anyprint has many glowing reviews from its many satisfied users: > > * "omg pls" > * "what is wrong with you" > * "That's stupid and not useful." > * "Please add my testimonial: "very accurate testimonials"." > * "kragniz, please stop writing questionable python metamodules :v"
For the love of god, please stop using endl. It performs a flush when "\n" is both valid and all that you ever want.
Also what happened to the std:: prefix?
If flushing after every line is good enough for printf then it's gonna be good enough for me~
> Are you saying you never want to flush?
90% of the time not. The other ten percent include asking for user input, which causes an implicit flush since std::cin is linked to std::cout, and debugging an ugly heisenbug.
NSLog(@"Hello, %s and %s!", @"macOS", @"iOS"); WRITE(*, *)
doable? How to handle the * isn't jumping out at me. `0:"Hello from K.\n" "Your text here".writeln;http://clarete.li/forbiddenfruit/?goback=.gde_50788_member_2...