dynamic-typing

Best place to coerce/convert to the right type in Python

I'm still fairly new to Python and I'm trying to get used to its dynamic typing. Sometimes I have a function or a class that expects a parameter of a certain type, but could get a value of another type that's coercible to it. For example, it might expect a float but instead receive an int or a decimal. Or it might expect a string, but in...

OOP and Dynamic Typing (not Static vs Dynamic)

What OOP principles, if any, don't apply or apply differently in a dynamically typed environment as opposed to a statically-typed environment (for example Ruby vs C#)? This is not a call for a Static vs Dynamic debate, but rather I'd like to see whether there are accepted principles on either side of that divide that apply to one and not...

Convert object type to subclassed object type in Objective-C

Say that I have Class A and Class B. Class B is a subclass of Class A. Class A contains some properties and then Class B extends the Class A superclass by adding some additional properties, specific to that subclass. I have created a Class A object and now wish to convert the object to be a Class B type object at runtime, so that I can a...

Dynamically typed class generates compiler warnings on method selection.

Perhaps this is the wrong way to go about this, but it seems like such a clean and workable approach that I wonder how I can make the compiler warning go away? @interface SomeView : UIView { NSString *stringOfsomeImportance; RelatedClass *niftyService; } @property (nonatomic, copy) NSString * stringOfnoImportance; @property (nonatomic...

Which languages are dynamically typed and compiled (and which are statically typed and interpreted)?

In my reading on dynamic and static typing, I keep coming up against the assumption that statically typed languages are compiled, while dynamically typed languages are interpreted. I know that in general this is true, but I'm interested in the exceptions. I'd really like someone to not only give some examples of these exceptions, but tr...

Static/Dynamic vs Strong/Weak

I see these terms banded around all over the place in programming and I have a vague notion of what they mean. A search shows me that such things have been asked all over stack overflow in fact. As far as I'm aware Static/Dynamic typing in languages is subtly different to Strong/Weak typing but what that difference is eludes me. Differen...

SQLite3's dynamic typing

SQLite3 uses dynamic typing rather than static typing, in contrast to other flavors of SQL. The SQLite website reads: Most SQL database engines (every SQL database engine other than SQLite, as far as we know) uses static, rigid typing. With static typing, the datatype of a value is determined by its container - the particular column...

Is there a compiled* programming language with dynamic, maybe even weak typing?

I wondered if there is a programming language which compiles to machine code/binary (not bytecode then executed by a VM, that's something completely different when considering typing) that features dynamic and/or weak typing, e.g: Think of a compiled language where: Variables don't need to be declared Variables can be created doing ru...

Does new 'dynamic' variable type in .NET 4.0 solve the single/multiple method dispatch issue in CLR?

The problem of single dispatch is mostly familiar to people engaged in coding with statically typed languages like Java and C#. The basic idea is: While the runtime polymorphism allows us to dispatch to the right method call according to the type (runtime type) of receiver, for example: IAnimal mything = new Cat(); mything.chop(); Th...

Java Best Practice for type resolution at runtime.

I'm trying to define a class (or set of classes which implement the same interface) that will behave as a loosely typed object (like JavaScript). They can hold any sort of data and operations on them depend on the underlying type. I have it working in three different ways but none seem ideal. These test versions only allow strings and i...

.NET generic class instance - passing a variable data type

As the title suggests, I'm tyring to pass a variable data type to a template class. Something like this: frmExample = New LookupForm(Of Models.MyClass) 'Works fine Dim SelectedType As Type = InstanceOfMyClass.GetType() 'Works fine frmExample = New LookupForm(Of SelectedType) 'Ba-bow! frmExample = New LookupForm(Of InstanceOfMyClass.Get...

Is the a pattern for iterating over lists held by a class (dynamicly typed OO languages)

If I have a class that holds one or several lists, is it better to allow other classes to fetch those lists (with a getter)? Or to implement a doXyzList/eachXyzList type method for that list, passing a function and call that function on each element of the list contained by that object? I wrote a program that did a ton of this and I hat...

How can I create a sequence of numbered variables at run time?

Friends, I must create a series of ArrayLists, each containing objects of unknown origin, with each instance assigned to a separate local variable. So far, so good... But I also need each local variable's name to follow a very specific pattern: the name should begin with "oArr", followed by one or more digits reflecting that particular...

Deserve dynamic typed languages all the criticism?

I have read a few articles on Internet about programming language choice in the enterprise. Recently many dynamic typed languages have been popular, i.e. Ruby, Python, PHP and Erlang. But many enterprises still stay with static typed languages like C, C++, C# and Java. And yes, one of the benefits of static typed languages is that progr...

Where do you benefit from dynamic typing?

How often do you take advantage of dynamic typing in a way that really wouldn't be feasible in a statically typed language? What I'm interested in is, how often these are used within real world (rather than demonstration) code? ...

Objective-C supertype polymorphism

Hi, I'm fairly new to Objective-C and wondering if it's possible to type objects as their supertype without receiving compiler warnings when assigning them, or if there is a recognised way of achieving the same thing? I realise that this is what type id is for but I have a base class with synthesized properties and if I try to use id ...

Do you know of any examples of elegant solutions in dynamically typed languages?

Imagine two languages which (apart from the type information) do have exactly the same syntax, but one is statically typed while the other one uses dynamic typing. Then, for every program written in the statically typed language, one can derive an equivalent dynamically typed program by removing all type information. As this is not necce...

Dynamic Typing without duck typing?

I'm used to dynamic typing meaning checking for type info of object/non object oriented structure at runtime and throwing some sort of type error, ie if it quacks like a duck its a duck. Is there a different type of dynamic typing (please go into details). ...

What's the difference between Object, *, and no type at all?

Is there any difference between those three declarations? var x; var y:Object; var z:*; Is there anything in AS that's not an Object? ...

Can I specify a specific superclass requirement for a class type variable?

I'm making a class that initializes instances of certain classes. This class will be used to initialize a few different types of classes all subclassed from a common super class. Currently I am using an instance variable: Class templateClass; to store the class type. I get compiler warnings saying methods aren't supported by templa...