Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!

Daniel Trebbien

Ranch Hand
+ Follow
since Jul 10, 2007
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
18
Received in last 30 days
0
Total given
75
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Trebbien

I saw mention of a "Kotlin/Native" (in addition to Kotlin/JVM and Kotlin/JS) in this other thread. This leads me to think that it might be possible in the future to run Kotlin code directly.

Have the designers of Kotlin considered whether it's possible to abandon type erasure? One of the things that I like about C# is that it supports generic programming and retains type information at runtime (see Type erasure: Java vs C#).

For platform types, I think that it would probably be impossible to retain type information at runtime. However, for Kotlin types, perhaps it's possible.

Is there room in the Kotlin language for retaining type information of generics at runtime, in a future version of Kotlin?
2 years ago
Reading about delegated properties, this seems similar to Python decorators, although it's nicely tailored to properties because the property delegate implements both getter and setter delegation routines.

Does the standard Kotlin library provide memoization and LRU cache property delegates?

Is there a way to make a "static" property delegate, if that makes sense; by this I mean, is it possible to use a single instance of the property delegate for all instances of the class, rather than each instance of the class having its own instance of the property delegate?

Are there other features that are unique to Kotlin?
2 years ago
Thank you, Liutauras Vilda!

For those curious, §16.39. Order of Evaluation states:

Generally, the order of evaluation is left to right, non-lazy (eager). Some expressions have special rules for order of evaluation of their constituent parts (some of them may be not evaluated at all). Order of evaluation of named arguments corresponds to their order at the invocation site, not the declaration site.

TODO



Also from the spec, §8.4. Unreachable Code:

Certain regions of code may be proved unreachable via static analysis, which results in a compile-time warning. Definite assignment is not checked within unreachable code, and assignment in unreachable code has no effect of definite assignment state of variables. Otherwise, unreachable code is not exempt from rules of this specification, and any violations result in errors in the same way as in reachable code. Compiler is free to skip code generation for any code proved to be unreachable, but this shall not have any observable effects (beyond those that can be obtained by inspection of the binaries).

2 years ago
Is there an effort to standardize the Kotlin language through an SDO, such as ISO or ECMA?
2 years ago
I looked on the Kotlin language website for a specification document, but could not find one.  How, for example, do you know what the order of evaluation of arguments is for a function call, and other pedantic issues?

Trying out Kotlin using the online editor, I was happy to see that "unreachable statements" appear not to be compile-time errors, unlike Java (see https://github.com/dtrebbien/JEP-Unreachable-Assertions/blob/aa528f5/jep.md ); the following code compiled with a warning rather than an error:



I am wondering, though, if this will be changed in a future version of Kotlin.

Is there a complete language specification document?
2 years ago
I am interested to know from the Kotlin in Action authors and knowledgeable Kotlin programmers whether there are language features of other programming languages that you wish Kotlin had.  If so, are there YouTrack issues to add these features?
2 years ago
Like Maven for Java and NPM for Node, is there a package manager that natively works with Kotlin projects?
2 years ago
I am interested in this question as well.  Automatic language translators/converters that I've used in the past have generated some weird code that took some effort to make workable.

Having just read about the concept of platform types (see https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types ), does the automatic translator built into IntelliJ tend to rely on type inference rather than explicit type denoting?

One further question:  Is the translator only available through IntelliJ or is it a standalone tool?
2 years ago
I am wondering: what are some reasons why one might prefer Kotlin rather than Haxe, and vice versa? Haxe purportedly supports targeting Android, Java, and JavaScript, but also supports a number of other platforms.
2 years ago
Are there advantages to placing CSS to style components in component CSS?
The angular-cli command ng init creates a basic Angular 2 app. One of the files that it creates is src/styles.css, and this is referenced in the angular-cli.json file.

When you follow the guides for adding Angular Material, in particular, the guide for Theming your Angular Material app, they show how to create a new SCSS (Sass CSS) file to define a custom theme, and add a reference to the new file in angular-cli.json.

Then there are styleUrls, which from what I understand are CSS files for styling a particular component.

What is the intended role of these three, different places to put CSS? When should I place CSS in component CSS (via styleUrls) or "global" stylesheets such as src/styles.css and the SCSS theme file?
I read a blog article which discusses how to use the Title service and listen to router events in order to change the page title when the user navigates to another path: https://toddmotto.com/dynamic-page-titles-angular-2-router-events

The article talks about using some features of RxJs and that the sample code requires the following imports:



Indeed, I found that this code sample from the article does not work without importing mergeMap:



The result of the filter() call has type Observable<ActivatedRoute>.

How can importing 'rxjs/add/operator/mergeMap' affect the methods that are available on the Observable type? Does TypeScript have a feature similar to C#'s extension methods?

I saw the Suggestion: Extension methods issue on GitHub, but from one of the comments, it appears that extension methods were not implemented: https://github.com/Microsoft/TypeScript/issues/9#issuecomment-236459998

Is that correct?
That's a good suggestion to create separate components. I will use this approach...
I integrated a Material Design tabs component with routing, so that clicking on a tab changes the URL, and visiting a certain tab's URL will cause the tab to be opened. See my Plunker: http://plnkr.co/edit/xNUO08jgFcFCsdWDzCRZ (it helps to click the "Launch the preview in a separate window" button to see the changing URL).

What I would like to do is, if the user goes back and a tab is focused, I would like to move the focus to the previous tab.

To see what I mean, run the Plunker that I linked to. When you see the tabs rendered, click on "Tab 3" to open the third tab. Right click on "Tab 3" and select "Back" from the context menu (in Firefox, the "back" menu item is just an arrow icon). The blue tab underline will move to "Tab 1" and the first tab will be opened; however, the focus is still on "Tab 3". I would like to move the focus to "Tab 1".