Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

static and dynamic types

 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dynamic types as the name indicates are said to gain or lose types during the life of the object. Can someone clarify this with a little example?
Thanks.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we are speaking about UML here, this is probably a conceptual categorization, without direct applicability at the implementation level.
What are your doubts?
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I think about it, it sounds a lot like dynamic classification. Didn't find any information about dynamic types, though...
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess it's a feature provided by a language.
With Java there is no way to change the type of an object at runtime.
I never used Smalltalk. But It seems that In Smalltalk, when you declare a variable, you need no specify the type. So any type can be assigned to this variable. I guess this means dynamique types.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct that Smalltalk is a dynamically typed language. But that doesn't mean that an *object* can change its type, only that *variable* aren't typed - which is a big difference!
It seems to me that the OP is talking about something else here.
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd imagine that in a language with late binding (so a "type" is effectively defined by whether an object understands a message or not) and the ability to add or remove methods at runtime would offer this facility.
I'm pretty sure self has this ability, and JavaScript probably does too.
What I'm not sure of is how much use it might be in practice. Does anyone have an example of where a model or a solution might need this sort of flexibility?
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is an excerpt from UML User Guide Chapter 11 (Interfaces, Types and Roles), topic "Modelling Static and Dynamic Types"

However, when you are modeling things like business objects, which naturally change their roles throughout a workflow, it's sometimes useful to explicitly model the dynamic nature of that object's type. In these circumstances, an object can gain and lose types during its life


I guess gaining or losing types is analogous to what Frank says as "the ability to add or remove methods at runtime would offer this facility"
I guess
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the quote, it seems to me to be something primarily meant to be used for the analysis model.

Originally posted by Frank Carver:
I'd imagine that in a language with late binding (so a "type" is effectively defined by whether an object understands a message or not)


I always understood "late binding" to refer to polymorphic method calls in general (the binding of the message call to the actual method occurs "late" at runtime). What you are referring to seems to be dynamically typed languages.

and the ability to add or remove methods at runtime would offer this facility.


Yes. I am not sure about the usefullness, too...
 
Destroy anything that stands in your way. Except this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic