+ 3
Can you create functions out of thin air?
So let me rephrase my question.. I mean, is it possible to open a blank page and create variables and functions and the text editor acts accordingly to whatever random stuff you create or is there a set of words we have to use to get the text editor to behave the way we want? Sorry if this is confusing.. Iâm just thinking about the example, print(âhello world!) What if I wanted to use display(âhello world!) ?? Would I get a reaction from the computer or is there no way to do this?
5 Answers
+ 5
Not sure about other languages, but in python that's totally possible. You can redefine everything to your liking. You just need to create a function display(string) and define what it does (print the string to the screen). I don't necessarily see why you would want to do that, but it's possible.
In other languages like C++, you can use macros in order to customize the syntax of the language. Technically it should be possible to replace cout << x with something like display x
+ 2
Do you mean something like that:
https://code.sololearn.com/cYjt76C4EcOs/?ref=app
https://code.sololearn.com/c88GL2chwh65/?ref=app
+ 1
In Python you can safe your costomized Functions and call them as Modules:
https://www.sololearn.com/learn/Python/2438/?ref=app
+ 1
Yes you can do that in Python .You have to display("hello world") and then define the function (print display)
0
ok, your first link made sense sebastian. I suppose by doing somebting like
print = cout
you can modify the code to your liking!
now, is there a text editor that gives me the fliexibility to set custom code or do I have to set it for each project?
thanks for the help !