RSS BotMB to Hacker NewsEnglish · 4 days agoWren: A classy little scripting languagewren.ioexternal-linkmessage-square9fedilinkarrow-up18arrow-down10file-text
arrow-up18arrow-down1external-linkWren: A classy little scripting languagewren.ioRSS BotMB to Hacker NewsEnglish · 4 days agomessage-square9fedilinkfile-text
minus-squareCochise@lemmy.eco.brlinkfedilinkEnglisharrow-up1·4 days agoThis is common on OOP. https://en.wikipedia.org/wiki/Function_overloading
minus-squarewhiwake@sh.itjust.workslinkfedilinkEnglisharrow-up1·4 days agoYes. Which frequently leads to complications. #include <iostream> using namespace std; void log(int level) { cout << "Logging numeric level: " << level << endl; } void log(string message) { cout << "Logging message: " << message << endl; } int main() { log('A'); // Uh oh — which one is this? }
minus-square𝙲𝚑𝚊𝚒𝚛𝚖𝚊𝚗 𝙼𝚎𝚘𝚠@programming.devlinkfedilinkEnglisharrow-up3·4 days agoThe level one. But that’s more due to implicit casting rather than function overloading imo.
This is common on OOP.
https://en.wikipedia.org/wiki/Function_overloading
Yes. Which frequently leads to complications.
#include <iostream> using namespace std; void log(int level) { cout << "Logging numeric level: " << level << endl; } void log(string message) { cout << "Logging message: " << message << endl; } int main() { log('A'); // Uh oh — which one is this? }The level one. But that’s more due to implicit casting rather than function overloading imo.