Yuescript: Can YUE support empty block and some logical falsity?

Can YUE support empty block and some logical falsity?

  • I hope Yue can support empty block code act as place holder for TODO and comments. Maybe we can use keyword ‘pass’ like python for this task. EX:
if os == 'win'
  print 'great'
else if os == 'mac'
  pass
else
  -- TODO: implement
  pass
  • I have some personal problem with lua ‘FALSITY’. Well… when work with some other languages and yue/lua at same time, I have a tenacity to make this error: “nil and false are the only false values”. It would nice if lua behave with 0 and “” like other languages. I known I can write a function or macro to achieve this. But this make code inconvenience and look ugly. Can Yue introduce a real ‘FALSITY’ logical operator do the dirty stuff. EX:
if !val
  print 'FALSE'
if !!val
  print 'TRUE'

==> Lua

if not val or val == 0 or val == "" then
  print 'FALSE'
end
-- if val and val ~= 0 and val ~= "" then
-- or
if not (not val or val == 0 or val == "") then
  print 'TRUE'
end
  • Support nullish coalescing operator like other modern languages. Maybe we can use ‘??’ op like javascript, C#. EX:
valA = nullValue ?? "default for A"
valB ??= "default for B"

==> Lua

local valA
if nullValue ~= nil then
  valA = "default for A"
end
local valB
if valB ~= nil then
  valB = "default for B"
end

Thanks and regards!

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 21 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Wouldn’t it be much easier to read if you just had a pass instruction?

It won’t be hard to get all the functions implemented. Just wanted to show that anyone can extend this language at will without even touching the source code.

You need to add a nil at the end of the code. Or the <- $skip macro will be treated as the last expression to be implicitly returned. So this example should be:

macro skip = -> ""

do
  print 1
  <- $skip
  print 2
  print 3

nil

Wouldn’t it be much easier to read if you just had a pass instruction?