All paths lead to... $path

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
We'll soon be merging code adding a new enumerated type to ASH (and JavaScript!). A few functions will become redundant (path_name_to_id, path_id_to_name and my_path_id) and you'll see warnings in your GCLI when running code that uses them.

I'd like to merge this in around 11 hours (9pm in the UK) as ASH is unaffected and major JavaScript library maintainers have been notified. Please let me know if you have any good reason I should delay that merge.

ASH

ASH code should be unaffected - our script parser can handle coercion between path names and path objects. This means that when the parser sees

Code:
if (my_path() == "Trendy") {

it will notice the type mismatch and quietly turn that into

Code:
if (my_path() == to_path("Trendy")) {

Hooray!

JavaScript

In JavaScript things are much the same... except one thing. You may have wondered "what is the difference between == and === in JavaScript?" Well this is a great example of the difference. == allows coercion like ASH does. === does not allow it. That means the following will soon be the case in JavaScript:

Code:
myPath() == "Trendy"; // returns: true
myPath() === "Trendy"; // returns: false
myPath() === Path.get("Trendy"); // returns: true
 

Magus_Prime

Well-known member
In the scripts that I have installed I see my_path_id() used in the following:
  • Autoscend
  • ChIT
  • TourGuide
  • Ezandora-Asdon-Martin-GUI
  • Ezandora-Bastille
  • Ezandora-Consume
  • Ezandora-Genie
  • Ezandora-Helix-Fossil
  • Ezandora-Source-Terminal-GUI
  • Excavator
  • PocketFamiliars
 
Last edited:

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
my_path_id() isn't going anywhere, but there should now be deprecation messages when using them
 

Magus_Prime

Well-known member
I know. I was just reporting it for general awareness. Presumably, as time goes by, script authors will make updates. Then I'll make the changes manually for those scripts that haven't been updated in a while or are no longer maintained.
 

ckb

Well-known member
To clarify, does this mean that a correct ASH usage would be something like:
Code:
if (my_path() == $path[Trendy]) {
 

Veracity

Developer
Staff member
Or

Code:
my_path().name == “Trendy”

The first is more efficient since it doesn’t do a string comparison.
 
Top