|
In Python you can inherit from int (something like):
class AgeInYears(int):
unit = "years"
def __new__(cls, age:int):
cls.age = age
return int.__new__(cls,age)
def __str__(self):
return "{} {}".format(self.age, self.unit)
def __add__(self, value:int):
self.age += value
return self
class User():
def __init__(self, age:int):
self.age = AgeInYears(age)
def __str__(self):
return "User: age: {}".format(self.age)
And then use it like:
user = User(29)
print(user)
print(user.age)
print(type(user.age))
user.age += 2
print(user.age)
print(type(user.age))
Of course, you still have to override some default methods of int (new, add).
This should cover the semantics nicely: you have an int, with unit, you can do basic int operations.
Ed
|
|
|
|
|
Well, that is very snazzy - I'll take a closer look at Python now. Thank you for taking the time to put together that example.
Marc
|
|
|
|
|
I'm sorry but this has to be amongst the most pointless discursions this forum has ever seen!
Quote: int age = 51;
A perfect encapsulation of an immutable truth ... age is just a number! What more could you possibly need?
|
|
|
|
|
Member 9082365 wrote: A perfect encapsulation of an immutable truth ... age is just a number! What more could you possibly need?
OK, what's 34 (besides "just a number") ?
Marc
|
|
|
|
|
Unless you're a thoroughgoing Pythagorean that question is no more meaningful than 'how is 34?' or 'why is 34?' It is just a number and as we all know (post pi) number doesn't exist in any real sense at all. As written it is an arbitrary typographical representation of a concept within an equally arbitrary logical system that bears no relation other than by extrapolation with what is, was or will be. It is an abstraction. A useful abstraction but an abstraction nonetheless.
And doubly so once you bring time into it! Contrary to popular opinion even if we were born simultaneously our real ages are almost certainly different! That's relativity for you!
|
|
|
|
|
Actually, most people would consider that numbers are as real as most human concepts, if not more so due to their universal applicability.
By your logic trees don't exist because "tree" is purely a label we've conjuured up to describe the commonality of all trees. Colours do not exist because "colour" is a word we use to describe colours of all objects. So if anything exists then numbers are as real as anything else - just because they have no physical form does not render then nonexistant. If you reject naming things, then you reject language and symbolic systems as a means of communicating. Good luck with that.
I'd suggest Wittgenstein's Philosophical Investigations for a more thorough consideration of this area.
More interesting questions he tackles are of the form "what is a game" - now that really is hard to tie down.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
But trees don't exist and 'tree' is indeed a label we've conjured up not to describe the commonality of certain plant species but to generalise sufficiently to deal with the fact that there is very little commonality in reality but life is way too short to demand strict accuracy in language. I'm surprised that you find anything to the contrary in Wittgenstein (although I appreciate that interpreting Wittgenstein depends very much on what mood he was in at the time of writing!)
And where do I reject symbolic systems and naming? I simply accept Kant's logic that we never do and never can know what is really there. In other words the fact that you can name something or fit it perfectly into a logical system does not make it an ontological necessity. The ability to speak of 'number' or 'trees' and use those concepts in the most complicated yet logical manner does not mean that number or tree actually exist. Even the most rigorous of ontological 'proofs' will always fall prey to the fact that they are a product of the logical system in which they operate and therefore require an unjustifiable acceptance of that system.
Of course, for the conduct of everyday life I bandy terms like tree and 34 about without the slightest embarrassment. It keeps one out of mental health institutions for starters! But that doesn't require commitment to the notion that they connotate anything real. If Hume could play billiards and at the same time believe that there was no such thing as cause and effect a little duality of thinking can't do any harm!
|
|
|
|
|
|
Member 10199043 wrote: PROLOG
Hmmm.
Prolog is an untyped language. Attempts to introduce types date back to the 1980s,[42][43] and as of 2008 there are still attempts to extend Prolog with types.[44] Type information is useful not only for type safety but also for reasoning about Prolog programs.
Marc
|
|
|
|
|
You could use C/C++
typedef int AgeInYears;
AgeInYears myAge = 51;
No need to define operators etc.
You could even use Ada
type AgeInYears is new Integer;
type AgeInMonths is new Integer;
myAge: AgeInYears;
yourAge: AgeInMonths;
Ada won't let you type
myAge := yourAge / 12;
unless you cast it.
|
|
|
|
|
An interesting language for doing this type of thing is Julia (http://julialang.org/[^]). In Julia you can A) Use typedefs to indicate that AgeInYears is a typedef for Int or B) Make a new type AgeInYears that is a subtype of Integer and implement a converter function (these are a standard Julia concept) from Int to AgeInYears so that age::AgeInYears = 5 will resolve correctly.
|
|
|
|
|
aschmahmann wrote: An interesting language for doing this type of thing is Julia (http://julialang.org/[^]).
Reading the docs, that looks very very interesting! Thank you for pointing out Julia!
Marc
|
|
|
|
|
// In C langage (or C++) you could write :
typedef int years;
typedef unsigned years ageInYears;
ageInYears myAge = 50;
// is not that enought ?
|
|
|
|
|
|
just don't use Facebook.
I'd rather be phishing!
|
|
|
|
|
Maximilien wrote: just don't use Facebook.
Always the best advice.
|
|
|
|
|
Maximilien wrote: just don't use Facebook. WHAT??? What ARE you rambling about, man? Without Facebook, how would people know what I had for lunch today? And other REALLY important stuff???
[Edit]
Clickety added[^]
[/Edit]
Anything that is unrelated to elephants is irrelephant Anonymous ----- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944 ----- I'd just like a chance to prove that money can't make me happy. Me, all the time
modified 17-Dec-13 11:06am.
|
|
|
|
|
Instagram?
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
Why would anybody browse the Internet without some sort of adblocking software installed? That takes care of the problem and all of the other annoying advertisements at the source.
Hogan
|
|
|
|
|
Ads on FB are inserted into the page directly from the FB domain rather than a third-party, so anything that blocks the ads breaks the site. Same thing with the DoNotTrackMe add-in for Firefox: FB simply will not work if it is active.
Sadly, the coders at Facebook are reasonably competent. Now that it is a publicly traded company, this kind of crap is only going to get worse. I just hope things get so bad that my family abandons it; with everyone spread out over several states, it's our main way to stay in touch.
|
|
|
|
|
Gregory.Gadow wrote: anything that blocks the ads breaks the site. That fixes the problem then
Gregory.Gadow wrote: I just hope things get so bad that my family abandons it; with everyone spread out over several states, it's our main way to stay in touch. Unless there's a reasonable alternative at the same price, there's probably no abandoning.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
What do I do if I've updated my Flash Player but am still getting the error message?
Already have the latest version of Flash Player, but still getting an error message?
If you're using Internet Explorer, this might be an issue with a setting in your browser. Don't worry, it's easy to fix:
• Click the tools gear in the top right corner of your Internet Explorer window
• Select 'safety' to open the safety sub-menu
• Make sure there is no check mark next to the 'ActiveX Filtering' option
• If there is a check mark, click on it to remove it
So, how do we allow it for some sites, but not others?
|
|
|
|
|
|
Sorry John, smells like spam... You've been a member for 2 years and this is your only post.
[Edit] And I'm not stuck, I like where I am.
It was broke, so I fixed it.
|
|
|
|
|
Agreed - traffic driver spam, reported message and author.
|
|
|
|