by Alex Nadalin

通过亚历克斯·纳达林

ABS 1.1.0:更多Python和Bash提供最有趣的编程语言 (ABS 1.1.0: more Python and Bash for the most fun programming language out there)

If you missed my previous post, ABS is a programming language that allows you to interact with the underlying system with a modern syntax. This is an example of it as a version of Bash built in 2019.

如果您错过了我以前的文章 ,ABS是一种编程语言,它允许您使用现代语法与底层系统进行交互。 这是它作为2019年构建的Bash版本的一个示例。

In this article, I’ll discuss a fresh new release of the ABS programming language, bringing more syntax you should be familiar with, inspired both by Bash and Python.

在本文中,我将讨论ABS编程语言的新发行版,在Bash和Python的启发下,带来您应该熟悉的更多语法。

This release includes 8 new features and 2 bugfixes, so let’s discover them together!

此版本包含8个新功能和2个错误修正,因此让我们一起发现它们!

更好的会员测试 (Better membership testing)

The membership testing operator, in, now supports finding whether an object has a particular key as well as allowing it to find substrings in strings:

成员资格测试运算符in ,现在支持查找对象是否具有特定键,并允许其查找字符串中的子字符串:

some in {"some": "thing"} # TRUEsome in {} # FALSE
"str" in "string" # TRUE"hello" in "string" # FALSE

With these changes to in we are now deprecating the set.includes(member) function:

通过这些更改in我们现在不建议使用set.includes(member)函数:

"string".contains("str")[1, 2, 3].contains(2)

The function will keep working but, again, is deprecated. We will likely not remove it from future releases (even major ones) but…you’ve been warned!

该功能将继续工作,但再次不推荐使用。 我们可能不会从将来的版本(甚至主要版本)中将其删除,但是…您已经得到警告!

1〜1.1 (1 ~ 1.1)

The similarity operator, ~, now supports numbers:

相似运算符~现在支持数字:

1 ~ 1.23 # TRUE1 ~ 0.99 # FALSE

Numbers will be similar if their integer conversion is the same. This is a shorthand for:

如果数字的整数转换相同,则数字将相似。 这是以下内容的简写:

1.int() == 1.23.int() # TRUE1.int() ~ 0.99.int() # FALSE

为..在 (for .. in)

We’ve made a few changes to for .. in to make it more useful, as you can now loop through hashes:

我们for .. in进行了一些更改for .. in以使其更有用,因为您现在可以遍历散列了:

for k, v in {"some": "thing"} {    # k is some     # v is thing }

更多的破坏力 (More destructuring)

We introduced destructuring before ABS was stable, updated it right before 1.0, and we’ve now expanded it to be able to destructure hashes:

我们在ABS稳定之前就引入了销毁方法,并在1.0之前对其进行了更新 ,现在我们对其进行了扩展以能够对散列进行销毁:

some, thing = {"some": 1, "thing": 1}some + thing # 2

反引号命令 (Backtick commands)

My absolute favorite feature in this release is the ability to execute commands with the backtick shell syntax:

在此发行版中,我绝对喜欢的功能是能够使用反引号shell语法执行命令:

`ls -la`
# previously you could only do$(ls -la)

There were some limitations with the $() syntax (namely, a command needs to be on its own line) that are not there anymore with backticks. Now you can do things such as:

$()语法有一些限制(即,命令必须在其自己的行上),而反引号则不再存在。 现在,您可以执行以下操作:

if `somecommand`.ok {    ...do something...}
# This is not possible, $() needs its own line$(somecommand).ok

The same interpolation style available with $() is working with backticks:

$()可用的相同插值样式适用于反引号:

arg = "-la"`ls $arg`

睡眠(毫秒) (sleep(ms))

Well…every language has one!

好吧……每种语言都有一种!

You can now pause execution of a script by sleeping for a certain amount of milliseconds:

现在,您可以通过Hibernate一定的毫秒数来暂停脚本的执行:

echo("This will be printed immediately")sleep(10000)echo("This will be printed in 10s")

哈希内置函数 (Hash builtin functions)

With this release we’ve added a bunch of new built-in functionalities to hashes:

在此版本中,我们为哈希添加了许多新的内置功能:

hash = {"a": 1, "b": 2, "c": 3}
hash.keys() # ["a", "b", "c"]hash.values() # [1, 2, 3]hash.items() # [["a", 1], ["b", 2], ["c", 3]]hash.pop(a) # hash is now {"b": 2, "c": 3}

NULL比较 (NULL comparison)

In ABS 1.0.0 we introduced a bug that would make NULL comparison fail:

在ABS 1.0.0中,我们引入了一个使NULL比较失败的错误:

null == null # FALSE

In 1.2.0 we fixed it (and backported it to 1.0.2).

在1.2.0中,我们对其进行了修复(并将其反向移植到1.0.2 )。

索引分配 (Index assignments)

Assigning to the index of a hash / array now works:

现在可以分配给哈希/数组的索引:

array = []array[0] = 1 # array is now [1]array[5] = 1 # array is now [1, null, null, null, null, 1]
hash = {}hash.x = 1 # hash is now {"x": 1}

你在等什么? (What are you waiting for?)

bash <(curl https://www.abs-lang.org/installer.sh)

…and start scripting like it’s 2019!

…开始编写脚本,就像2019年一样!

PS: Again, many thanks to Erich, who’s been helping me along the way and has become a crucial member of the team over the past few weeks. Just want to make sure his name is mentioned as most of this stuff would not have been possible without him!

PS:再次感谢Erich ,他一直在帮助我,并在过去几周内成为团队的重要成员。 只是想确保提到他的名字,因为没有他,大多数东西都是不可能的!

PPS: 1.2.0 is already well underway — expect it within the next 2 to 3 weeks. We’ll be introducing extremely interesting features such as background commands and REPL history, so it’s going to be an exciting release!

PPS: 1.2.0已经很好地进行了 -预计在接下来的2-3周内。 我们将引入非常有趣的功能,例如后台命令和REPL历史记录,因此它将是一个令人兴奋的发行版!

Originally published at odino.org.You can follow me on Twitter — rants are welcome! ?

最初在odino.org上发布。 您可以在Twitter上关注我-欢迎咆哮!

翻译自: https://www.freecodecamp.org/news/abs-1-1-0-more-python-and-bash-for-the-most-fun-programming-language-out-there-d62806b1cf53/

ABS 1.1.0:更多Python和Bash提供最有趣的编程语言相关推荐

  1. python数据分析软件0代码,python数据分析软件开发

    大家好,小编为大家解答python数据分析软件0代码的问题.很多人还不知道python数据分析处理软件,现在让我们一起来看看吧! 1.sas和python的区别 sas和python的区别: 1.成本 ...

  2. 【Python 星球1.0】 Python简介

    文章目录 关于 Python 名字背后的故事 Python 的特点 简单 易于学习 免费开源 高级语言 可移植 解释性(和编译性相对) 面向对象 可扩展 可嵌入 丰富的库 总结 Python 3 和 ...

  3. 如何使用 Python 或 Bash动态生成 Jekyll 配置文件

    使用 Python 或 Bash 将动态数据插入 Jekyll 静态网站中,并且避免创建一个 API 后端. 静态网站生成器 Jekyll 使用 _config.yml 进行配置.这些配置都是 Jek ...

  4. 如何友好的把Python和Bash结合在一起

    对于Linux用户而言,命令行操作我们已经非常熟悉了.与其他流行的操作系统不同,在Linux社区中,使用命令行与使用图形用户界面执行类似任务相比,命令行通常可以提供更优雅,更有效的解决方案. 随着Li ...

  5. python3.7基础教程_关于本教程 |《Python 官方文档:入门教程 3.7.0》| Python 技术论坛...

    本文档最新版为 3.8,旧版本可能放弃维护,推荐阅读最新版! Python 入门教程 Python 是一门简单易学且功能强大的编程语言.它拥有高效的高级数据结构,并能够用简单又有效的方式进行面向对象编 ...

  6. 更多python内容请移步

    本想把两个博客合并到一起,不过在这里测试后发现格式不太满意. 只能辛苦大家,要看更多python内容请移步至 https://www.cnblogs.com/lrtao2010/ 转载于:https: ...

  7. python解释器源码 pdf_《python解释器源码剖析》第0章--python的架构与编译python

    本系列是以陈儒先生的<python源码剖析>为学习素材,所总结的笔记.不同的是陈儒先生的<python源码剖析>所剖析的是python2.5,本系列对应的是python3.7. ...

  8. python与人工智能编程-Python是人工智能和机器学习的最佳编程语言,证据在此!...

    人工智能与机器学习是IT行业的新兴热门领域.虽然有关其发展安全性的讨论日益增多,但开发人员仍在不断扩展人工智能的能力与存储容量.如今,人工智能已远远地超出科幻小说中的构想,成为了现实.人工智能技术广泛 ...

  9. 趁着课余时间学点Python(十五)有趣的小模块

    一.Python模块与包 python中模块与包的含义 1. Python模块与包 模块是单个的py文件,包是包含多个py文件的文件夹 1.1 模块 模块是一个py文件 我们自己创建一个py文件就是一 ...

最新文章

  1. linux dd 大文件下载,Linux dd+grep 大文件二分查找
  2. tensorflow编程入门笔记之一
  3. Dev C++ 无法调试问题的解决——小白也能看懂!
  4. chromebook刷机_如何在Chromebook上切换(或离开)Canary频道
  5. Java转置_Java实现单链表的逆转置
  6. 单片机定时器_单片机定时器/计数器基本原理
  7. 解决方案-vector初始化后存放Mat,出现Mat矩阵数据同变问题
  8. JavaStudy13(MySQL)—B站韩顺平
  9. 程序员必备的5个工作技能
  10. Airtest网易自动化测试工具
  11. 针对瑞萨单片机编译时空间无法全部使用问题的解决方案
  12. Python解决买五赠二问题
  13. 多元线性回归和正规方程解
  14. varchar和text的区别
  15. 为JY61加入OLED显示系统
  16. BZOJ1455罗马游戏
  17. 华为AX3Pro+旁路由+Zerotier实现外网访问家里设备
  18. 计算机组成原理实验扩展RCL指令,计算机组成原理实验五扩展指令设计.doc
  19. Discuz论坛代码
  20. VS2015创建msi

热门文章

  1. 华科05年计算机考研复试机试
  2. 日期控件的用法 winform
  3. 认识网页 网页的组成 0907
  4. 爬虫,反爬工具fake-useragent,随机useragent模块教程
  5. python-jieba分词模块
  6. sublime-cssrem-安装与使用
  7. jiffies回绕问题
  8. Eclipse直接打开类文件/文件夹所在的本地目录
  9. 统计一个数组中正数和负数的个数
  10. MVC的初步认识理论