ClojureScript 点访问格式

本文探讨了Clojure与ClojureScript在属性访问及方法调用语法上的差异,并提出了改进方案以缩小两者间的差距。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这份资料找的我想吐,赶快来收藏一下。让你写出无与伦比的代码的葵花宝典。
当前提供的格式

(.p o) ;=> 属性访问 (.m o <args>) ;=> 方法调用 带参数 (. o p) ;=> 属性访问 (. o p <args>) ;=> 方法调用 带参数 (. o (m)) ;=> 方法调用 (. o (m <args>)) ;=> 方法调用 带参数

将来可能支持的:

(.p o)           ;=> 属性访问 p是属性

(.p o)           ;=> 方法调用 p是方法

(.m o <args>)    ;=> 方法调用

(. o p)          ;=> 属性访问 p是属性

(. o p)          ;=> 方法调用 p是方法

(. o p <args>)   ;=> 方法调用

(. o (m))        ;=> 方法调用

(. o (m <args>)) ;=> 方法调用

The divergence between the Clojure and ClojureScript way is due to first-class functions. That is, in JavaScript a property can be a field or a function or a method. There is currently no way to distinguish between the desire to call a method and retrieve a function as a property except through syntax. This ticket would shorten the gap between Clojure and ClojureScript in the following way (ClojureScript proposal below)(原话就这样了,我也不翻译了。):

(.m o)           ;=> a method call

(.m o <args>)    ;=> a method call

(. o m)          ;=> a method call

(. o m <args>)   ;=> a method call

(. o (m))        ;=> a method call

(. o (m <args>)) ;=> a method call

(.-p o)          ;=> a property access

(. o -p)         ;=> a property access

说实话,看的我有点晕,附上原文地址:
网页
 
 


转载于:https://www.cnblogs.com/snakevash/archive/2013/04/08/3007473.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值