Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does hybrid typing work?

Tags:

typing

raku

Wikipedia says "Perl 6 offers a hybrid typing system whereby the programmer may choose to use static typing, use dynamic typing, or mix the two." How does hybrid typing work? Does using static typing in Perl simply mean that I declare a type, and have to explicitly cast strings to numbers and vice versa in exchange for safety and run time speed? I've noticed there seems to be very little information on this feature.

like image 806
Jeff Linahan Avatar asked Jul 17 '15 20:07

Jeff Linahan


People also ask

How will hybrid working work?

A hybrid work model provides employees with greater flexibility and the option to work from home or anywhere they can be productive. With hybrid work, the workplace is no longer inside the four walls of the corporate office—it's an ecosystem of employees working from home, in coworking spaces, and the office.

What is hybrid work type?

A hybrid work model is a workforce structure that includes employees who work remotely and those who work on site, in a company's facilities.

What does hybrid mean in a job posting?

Hybrid work is a flexible approach that allows employees to split their time between working in the office and working from home. Hybrid work varies in flexibility. Here are some different types of hybrid work policies companies are using: Hybrid at-will: Employees can choose which day(s) to come into the office.


1 Answers

As I understand it, hybrid typing simply means that type annotations are supported, but optional:

my Int $i = 0; # static typing
my $i = 0; # dynamic typing

When you use the explicit type annotations, the compiler may check things for you and maybe optimize the code better. There are similar features in other languages, too, like Objective-C:

NSString *foo = @"foo"; // explicit type signature, static typing
id foo = @"foo"; // dynamic typing

Technically speaking, this is not exactly the difference between static and dynamic typing. There are languages that have a static type system that doesn’t require the explicit type annotations. In Swift or Haskell, you can say things like let f = 0 (without a type annotation) and still get static type checking thanks to type inference. See also What to know before debating type systems.

There are also other, more interesting features regarding the difference between static and dynamic typing in Perl 6, see Jnthn’s talk.

like image 192
zoul Avatar answered Oct 13 '22 16:10

zoul